CI: add CodeQL workflow tests
[project/libubox.git] / blob.c
diff --git a/blob.c b/blob.c
index 433becb904f54d4e0b3fb186756f62c71beb0ba5..65adb139553f88766eb075f720a5687fe8f3ad28 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -58,6 +58,8 @@ blob_buf_grow(struct blob_buf *buf, int required)
 {
        int offset_head = attr_to_offset(buf, buf->head);
 
+       if ((buf->buflen + required) > BLOB_ATTR_LEN_MASK)
+               return false;
        if (!buf->grow || !buf->grow(buf, required))
                return false;
 
@@ -103,6 +105,7 @@ blob_buf_free(struct blob_buf *buf)
 {
        free(buf->buf);
        buf->buf = NULL;
+       buf->head = NULL;
        buf->buflen = 0;
 }