libcsv icon indicating copy to clipboard operation
libcsv copied to clipboard

null pointer check before usage

Open ferkulat opened this issue 8 years ago • 2 comments

ferkulat avatar Apr 08 '17 16:04 ferkulat

libcsv is c89 afaik and this would add mixed declarations which won't work in some versions of Visual Studio. csv_fini should not be called with NULL. Whether it needs parameter checking I think you should take that question upstream.

jay avatar Apr 08 '17 20:04 jay

Hello Jay, you are right. If a function is not expected to receive NULL. Then there is no check needed. But if you check for NULL, but use it before, then the compiler is free to optimize away unrelated code. Either check before usage or don't check. Please check example 2 on : https://blog.knatten.org/2011/11/04/undefined-behaviour-%E2%80%94-worse-than-its-reputation/

Thank you for your comment

ferkulat avatar Apr 08 '17 21:04 ferkulat