aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-12-20 10:52:54 (GMT)
committerJouni Malinen <j@w1.fi>2010-01-09 19:09:39 (GMT)
commit49198bb3eb202a8488169354f25f699aac36aa46 (patch)
tree089d718d15cbe8e0d851036fbd37007dd1b49866
parent73dcc64b40e69544a346aab1acd2dbcf0d465b06 (diff)
downloadhostap-06-49198bb3eb202a8488169354f25f699aac36aa46.zip
hostap-06-49198bb3eb202a8488169354f25f699aac36aa46.tar.gz
hostap-06-49198bb3eb202a8488169354f25f699aac36aa46.tar.bz2
wpabuf: Allow wpabuf_resize(NULL, len) to be used
This matches with realloc() usage, i.e., allocate a new buffer if no buffer was specified. (cherry picked from commit 859db534bf29e360adfdc7da6a0bf0ad86fc1ec2)
-rw-r--r--src/utils/wpabuf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/utils/wpabuf.c b/src/utils/wpabuf.c
index c544179..8181912 100644
--- a/src/utils/wpabuf.c
+++ b/src/utils/wpabuf.c
@@ -29,6 +29,10 @@ static void wpabuf_overflow(const struct wpabuf *buf, size_t len)
int wpabuf_resize(struct wpabuf **_buf, size_t add_len)
{
struct wpabuf *buf = *_buf;
+ if (buf == NULL) {
+ *_buf = wpabuf_alloc(add_len);
+ return *_buf == NULL ? -1 : 0;
+ }
if (buf->used + add_len > buf->size) {
unsigned char *nbuf;
if (buf->ext_data) {