openjpeg icon indicating copy to clipboard operation
openjpeg copied to clipboard

Remove unnecessary null pointer checks

Open elfring opened this issue 10 years ago • 4 comments

Extra null pointer checks are not needed in functions like the following.

Would you like to apply the following semantic patch to find more update candidates?

@Remove_unnecessary_pointer_checks@
expression x;
@@
-if (x)
    opj_free(x);

elfring avatar Sep 13 '15 07:09 elfring

As of now opj_free is using just free(), but as you can imagine that can change, so if as of now free() by C standard is checking for NULL inside, it can be not as such in the future.

ValZapod avatar Jan 13 '21 10:01 ValZapod

:crystal_ball: Will alternative implementations of the function “opj_free” tolerate also the passing of null pointers?

elfring avatar Jan 13 '21 13:01 elfring

I do not know many *alloc() and friends implementations outside C library and now Microsoft's leaked one, I know they exist. For example, there is this implementation. https://github.com/google/tcmalloc

ValZapod avatar Jan 13 '21 14:01 ValZapod

Do you expect null pointer tolerance for memory release functions?

elfring avatar Jan 13 '21 14:01 elfring