From: Jouni Malinen Date: Sun, 20 Dec 2009 10:52:54 +0000 (+0200) Subject: wpabuf: Allow wpabuf_resize(NULL, len) to be used X-Git-Tag: hostap_0_7_1~291 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=859db534bf29e360adfdc7da6a0bf0ad86fc1ec2;p=thirdparty%2Fhostap.git 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. --- diff --git a/src/utils/wpabuf.c b/src/utils/wpabuf.c index c5441790e..8181912ea 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) {