]> git.eshelyaron.com Git - emacs.git/commitdiff
Pacify -Wanalyzer-null-argument in lisp_malloc
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 3 Oct 2021 23:37:13 +0000 (16:37 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 3 Oct 2021 23:55:17 +0000 (16:55 -0700)
* src/alloc.c (lisp_malloc): Document that NBYTES must be
positive, and omit a needless runtime check.  This pacifies a
false alarm with gcc 11.2.1 -Wanalyzer-possible-null-dereference.

src/alloc.c

index 0895a0f52aa1cf58de0cc4b5188e735b86cb4cab..0c04d5cde05e598e66e4ff2bc0df01b31387c07f 100644 (file)
@@ -988,7 +988,8 @@ record_xmalloc (size_t size)
 
 /* Like malloc but used for allocating Lisp data.  NBYTES is the
    number of bytes to allocate, TYPE describes the intended use of the
-   allocated memory block (for strings, for conses, ...).  */
+   allocated memory block (for strings, for conses, ...).
+   NBYTES must be positive.  */
 
 #if ! USE_LSB_TAG
 void *lisp_malloc_loser EXTERNALLY_VISIBLE;
@@ -1030,7 +1031,7 @@ lisp_malloc (size_t nbytes, bool clearit, enum mem_type type)
 #endif
 
   MALLOC_UNBLOCK_INPUT;
-  if (!val && nbytes)
+  if (!val)
     memory_full (nbytes);
   MALLOC_PROBE (nbytes);
   return val;