BUG OF THE MONTH | The ‘paths’ object was used before it was verified against null
PVS-Studio warning: V3095 The ‘paths’ object was used before it was verified against null. Check lines: 304, 312. AdminController.cs 304
This error seems more exciting. At first glance, the code looks right. Although paths is used before a null check, the code doesn’t dereference a reference to this object explicitly. It’s not really that simple though. During the foreach loop iteration through the collection, the loop calls the GetEnumerator method. This leads to a NullReferenceException, and the program crashes.
Tip: Always be aware of the way different language constructs function, or use a reliable code-checking software solution.