github / github/codeql

LGTM.com - false positive - cs/dereferenced-value-is-always-null when passed by ref to a method like Array.Resize

未關閉
#2,753 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
C# false-positive
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

**Description of the false positive**

In general, the `cs/dereferenced-value-is-always-null` rule makes sense: https://lgtm.com/rules/1506094316834/

However, if a local is passed to a method by `ref`, it is possible that the method changes its value. In particular, if an array is null, `Array.Resize` will set it to not null. This applies generally to any method that accepts a parameter by `ref`.

https://github.com/dotnet/runtime/blob/c5805025613513ca71b905d3cdafdcba0769960d/src/libraries/System.Private.CoreLib/src/System/Array.cs#L43-L61

**URL to the alert on the project page on LGTM.com**

https://lgtm.com/projects/g/dotnet/corefx/snapshot/4fed824926d1c659c494bd5261fbae0236b2e9da/files/src/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/FormatterServices.cs?sort=name&dir=ASC&mode=heatmap#x520a4bc6d0c2a055:1

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。