Pacify GCC 14 -Walloc-size
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Apr 2024 08:20:12 +0000 (01:20 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Apr 2024 08:26:22 +0000 (01:26 -0700)
* src/xfns.c (xic_string_conversion_callback): Allocate size 1, not 0.

src/xfns.c

index d610c839bfc73cc3df7b31720973d1cb43aa610f..67db461a37935299b28e2fd9a279fa527aee377d 100644 (file)
@@ -3917,11 +3917,12 @@ xic_string_conversion_callback (XIC ic, XPointer client_data,
   return;
 
  failure:
-  /* Return a string of length 0 using the C library malloc.  This
+  /* Return a string of length 0 using the C library malloc (1)
+     (not malloc (0), to pacify gcc -Walloc-size).  This
      assumes XFree is able to free data allocated with our malloc
      wrapper.  */
   call_data->text->length = 0;
-  call_data->text->string.mbs = malloc (0);
+  call_data->text->string.mbs = malloc (1);
 }
 
 #endif /* HAVE_X_I18N */