javiersc Absent Member.
Absent Member.
4525 views

C# operator "?" (inline if) and null dereference

Hi all,

I'm performing security fixes in a quite large C# application and there are hundreds of Null Dereference issues, many of them are like the example below:

Inside an .aspx file:

            <td width="<%= booleanVariable ? "35%" : "" %>">test</td>

We've found out that everytime an aspx page contains an inline if (operator "?") like the example above, Fortify finds a Null Dereference issue. In the example above booleanVariable is not nullable, so it cannot be null by any means.

Do you know any way of solving this issue with a rule or any other way which doesn't require modifying the source code?

Regards,

Javier

Labels (1)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.