[cfe-dev] return value of malloc
Kristóf Umann via cfe-dev
cfe-dev at lists.llvm.org
Sat Apr 20 15:58:32 PDT 2019
Hi!
As far as I know, the analyzer is relatively conservative with such
functions, and only assumes that the returned value may be null, when it is
checked in the code, e.g.
int *a = (int*)malloc(sizeof(int));
*a = 5; // The analyzer won't assume that a may be null
if (a) {} // Now the analyzer will assume that it may be null as well.
Is your code structured like that?
Cheers,
Kristóf
+ Artem, am I correct here?
On Sat, 20 Apr 2019 at 23:05, Kihong Heo via cfe-dev <cfe-dev at lists.llvm.org>
wrote:
> Hi list,
>
> Is there a simple way for Clang Static Analyzer to assume that
> malloc-family functions always return non-null values?
> Otherwise, it would be appreciated if you point which part I should
> change to do that.
>
> Thanks,
> Kihong
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190421/d7a5043a/attachment.html>
More information about the cfe-dev
mailing list