lua/flowvarlib: check malloc result

src/util-lua-flowvarlib.c:110:12: warning: If memory allocation fails, then there is a possible null pointer dereference: buf [nullPointerOutOfMemory]
    memcpy(buf, value, len);
           ^
src/util-lua-flowvarlib.c:109:28: note: Assuming allocation function fails
    uint8_t *buf = SCMalloc(len + 1);
                           ^
src/util-lua-flowvarlib.c:109:28: note: Assignment 'buf=malloc(len+1)', assigned value is 0
    uint8_t *buf = SCMalloc(len + 1);
                           ^
src/util-lua-flowvarlib.c:110:12: note: Null pointer dereference
    memcpy(buf, value, len);
           ^
src/util-lua-flowvarlib.c:111:5: warning: If memory allocation fails, then there is a possible null pointer dereference: buf [nullPointerOutOfMemory]
    buf[len] = '\0';
    ^
src/util-lua-flowvarlib.c:109:28: note: Assuming allocation function fails
    uint8_t *buf = SCMalloc(len + 1);
                           ^
src/util-lua-flowvarlib.c:109:28: note: Assignment 'buf=malloc(len+1)', assigned value is 0
    uint8_t *buf = SCMalloc(len + 1);
                           ^
src/util-lua-flowvarlib.c:111:5: note: Null pointer dereference
    buf[len] = '\0';
pull/13170/head
Victor Julien 1 year ago committed by Victor Julien
parent 4e2f1de308
commit 223c568701

@ -107,6 +107,9 @@ static int LuaFlowvarSet(lua_State *L)
}
uint8_t *buf = SCMalloc(len + 1);
if (buf == NULL) {
return luaL_error(L, "alloc failure");
}
memcpy(buf, value, len);
buf[len] = '\0';
FlowVarAddIdValue(f, *flowvar_id, buf, (uint16_t)len);

Loading…
Cancel
Save