projects
/
oweals
/
busybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ba76b7a
)
vasprintf: do not use xmalloc, it will deadlock on OOM
author
Denys Vlasenko
<vda.linux@googlemail.com>
Thu, 7 Feb 2013 15:06:54 +0000
(16:06 +0100)
committer
Denys Vlasenko
<vda.linux@googlemail.com>
Thu, 7 Feb 2013 15:06:54 +0000
(16:06 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/platform.c
patch
|
blob
|
history
diff --git
a/libbb/platform.c
b/libbb/platform.c
index 2bf34f5bc9bd093d42974289edd22e43ca55aa67..d241d25a7679d4bb89efc2b7ee5b013e1c74620b 100644
(file)
--- a/
libbb/platform.c
+++ b/
libbb/platform.c
@@
-28,14
+28,16
@@
int FAST_FUNC vasprintf(char **string_ptr, const char *format, va_list p)
r = vsnprintf(buf, 128, format, p);
va_end(p);
+ /* Note: can't use xstrdup/xmalloc, they call vasprintf (us) on failure! */
+
if (r < 128) {
va_end(p2);
- *string_ptr =
x
strdup(buf);
+ *string_ptr = strdup(buf);
return r;
}
- *string_ptr =
x
malloc(r+1);
- r =
vsnprintf(*string_ptr, r+1, format, p2
);
+ *string_ptr = malloc(r+1);
+ r =
(*string_ptr ? vsnprintf(*string_ptr, r+1, format, p2) : -1
);
va_end(p2);
return r;