bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / code / Atom feed
* [PATCH] maint: pacify GCC 11.2 -fanalyzer in crypto tests
@ 2021-07-31 19:59 Paul Eggert
  0 siblings, 0 replies; only message in thread
From: Paul Eggert @ 2021-07-31 19:59 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

* tests/bench-digest.h (main): Report an error after memory
exhaustion, instead of using a null pointer.
---
 ChangeLog            | 6 ++++++
 tests/bench-digest.h | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index e35192a9e..80bcabd22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-07-31  Paul Eggert  <eggert@cs.ucla.edu>
+
+	maint: pacify GCC 11.2 -fanalyzer in crypto tests
+	* tests/bench-digest.h (main): Report an error after memory
+	exhaustion, instead of using a null pointer.
+
 2021-07-30  Paul Eggert  <eggert@cs.ucla.edu>
 
 	xalloc: add malloc-related function attributes
diff --git a/tests/bench-digest.h b/tests/bench-digest.h
index 96a449924..3ded94119 100644
--- a/tests/bench-digest.h
+++ b/tests/bench-digest.h
@@ -82,6 +82,11 @@ main (int argc, char *argv[])
   int repeat = atoi (argv[2]);
 
   char *memblock = (char *) malloc (size);
+  if (!memblock)
+    {
+      fprintf (stderr, "%s: memory exhausted\n", argv[0]);
+      return 1;
+    }
 
   /* Fill the memory block.  */
   {
-- 
2.31.1



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-31 19:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31 19:59 [PATCH] maint: pacify GCC 11.2 -fanalyzer in crypto tests Paul Eggert

Code repositories for project(s) associated with this inbox:

	../../../mirrors/gnulib.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).