]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Make xmalloc diagnostic suppression conditional
authorRuss Allbery <eagle@eyrie.org>
Mon, 25 Dec 2023 22:25:11 +0000 (14:25 -0800)
committerRuss Allbery <eagle@eyrie.org>
Mon, 25 Dec 2023 22:25:11 +0000 (14:25 -0800)
It looks like -Wuse-after-free was added in GCC 12, although it
doesn't appear in the changes. Make suppressing diagnostics about
it in util/xmalloc.c conditional on that version to avoid problems
on GitHub CI with an older GCC version.

util/xmalloc.c

index 21b53d5f206754fa2874872c727899d4e541b667..8495e60140f95d8d9c52651fc7e5639ad8bfef1b 100644 (file)
@@ -159,7 +159,7 @@ x_realloc(void *p, size_t size, const char *file, int line)
          * that if realloc fails (which is true in every case when it returns
          * NULL when size > 0), p is unchanged and still valid.
          */
-#if !defined(__clang__)
+#if __GNUC__ >= 12 && !defined(__clang__)
 #    pragma GCC diagnostic push
 #    pragma GCC diagnostic ignored "-Wuse-after-free"
 #endif
@@ -168,7 +168,7 @@ x_realloc(void *p, size_t size, const char *file, int line)
         newp = realloc(p, size);
     }
     return newp;
-#if !defined(__clang__)
+#if __GNUC__ >= 12 && !defined(__clang__)
 #    pragma GCC diagnostic pop
 #endif
 }
@@ -190,7 +190,7 @@ x_reallocarray(void *p, size_t n, size_t size, const char *file, int line)
          * every case when it returns NULL when size > 0 and n > 0), p is
          * unchanged and still valid.
          */
-#if !defined(__clang__)
+#if __GNUC__ >= 12 && !defined(__clang__)
 #    pragma GCC diagnostic push
 #    pragma GCC diagnostic ignored "-Wuse-after-free"
 #endif
@@ -198,7 +198,7 @@ x_reallocarray(void *p, size_t n, size_t size, const char *file, int line)
         (*xmalloc_error_handler)("reallocarray", n *size, file, line);
         newp = reallocarray(p, n, size);
     }
-#if !defined(__clang__)
+#if __GNUC__ >= 12 && !defined(__clang__)
 #    pragma GCC diagnostic pop
 #endif
     return newp;