malloc/calloc return value NULL check

David Holmes david.holmes at oracle.com
Mon Jul 14 03:28:09 UTC 2025


On 11/07/2025 10:57 pm, Baesken, Matthias wrote:
> Hi, when playing around with the  GCC static analyzer  ( https:// 
> developers.redhat.com/articles/2022/04/12/state-static-analysis-gcc-12- 
> compiler <https://developers.redhat.com/articles/2022/04/12/state- 
> static-analysis-gcc-12-compiler> )   I noticed
> 
> a lot of complaints about  missing  NULL checks of  malloc/calloc 
>   return values in the code base.

In hotspot codebase ??

> While we check these return values for NULL at a lot of places in the 
> codebase,  it is not done always.
> 
> Should we do it always  (except 3^rd party code probably where we do not 
> want to have large diffs to upstream) ?
> 
> Or is it considered not important enough  to do it always?

Yes we should be checking for null returns.

Why did you raise this on build-dev??

David
-----

> Best regards, Matthias
> 



More information about the build-dev mailing list