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.
This commit is contained in:
Jouni Malinen 2009-12-20 12:52:54 +02:00
parent c479e41f53
commit 859db534bf

View 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) {