Commit 46f19985 authored by Marek Vavruša's avatar Marek Vavruša

lib: fixed dead code and early dereference

parent 4a8c3a43
......@@ -115,12 +115,12 @@ static inline uint8_t *pack_obj_next(uint8_t *it)
*/
static inline int pack_obj_push(pack_t *pack, const uint8_t *obj, pack_objlen_t len)
{
uint8_t *endp = pack_tail(*pack);
size_t packed_len = len + sizeof(len);
if (pack == NULL || (pack->len + packed_len) > pack->cap) {
return -1;
}
uint8_t *endp = pack_tail(*pack);
memcpy(endp, (char *)&len, sizeof(len));
memcpy(endp + sizeof(len), obj, len);
pack->len += packed_len;
......
......@@ -253,7 +253,7 @@ static char* hint_get(void *env, struct kr_module *module, const char *args)
}
char *result = NULL;
asprintf(&result, "{ \"result\": [ %s ] }", hint_buf ? hint_buf : "");
asprintf(&result, "{ \"result\": [ %s ] }", hint_buf);
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment