]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpabuf: Allow wpabuf_resize(NULL, len) to be used
authorJouni Malinen <j@w1.fi>
Sun, 20 Dec 2009 10:52:54 +0000 (12:52 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 20 Dec 2009 10:52:54 +0000 (12:52 +0200)
This matches with realloc() usage, i.e., allocate a new buffer if no
buffer was specified.

src/utils/wpabuf.c

index c5441790e0bacfa80483213a575bcd8d7aa46605..8181912ea9f7be0885c5ed04172316e86fa6fd27 100644 (file)
@@ -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) {