Created
June 1, 2023 22:45
-
-
Save NatWeiss/0ea0fb0dd780497bb5084e09ee6301cd to your computer and use it in GitHub Desktop.
linux514-xrealloc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tools/lib/subcmd/subcmd-util.h b/tools/lib/subcmd/subcmd-util.h | |
index 794a375dad36..7009fc176636 100644 | |
--- a/tools/lib/subcmd/subcmd-util.h | |
+++ b/tools/lib/subcmd/subcmd-util.h | |
@@ -49,13 +49,12 @@ static NORETURN inline void die(const char *err, ...) | |
static inline void *xrealloc(void *ptr, size_t size) | |
{ | |
- void *ret = realloc(ptr, size); | |
- if (!ret && !size) | |
- ret = realloc(ptr, 1); | |
+ void *ret; | |
+ if (!size) | |
+ size = 1; | |
+ ret = realloc(ptr, size); | |
if (!ret) { | |
ret = realloc(ptr, size); | |
- if (!ret && !size) | |
- ret = realloc(ptr, 1); | |
if (!ret) | |
die("Out of memory, realloc failed"); | |
} | |
-- | |
2.34.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment