Commit 785cb46a authored by Marek Vavruša's avatar Marek Vavruša

daemon: fixed memleak in network address pack

parent 426bb27d
......@@ -86,7 +86,10 @@ static int insert_endpoint(struct network *net, const char *addr, struct endpoin
array_init(*ep_array);
}
return array_push(*ep_array, ep);
if (array_push(*ep_array, ep) < 0) {
return kr_error(ENOMEM);
}
return kr_ok();
}
/** Open endpoint protocols. */
......
......@@ -127,9 +127,9 @@ static inline void array_std_free(void *baton, void *p)
* @return element index on success, <0 on failure
*/
#define array_push(array, val) \
(array).len < (array).cap ? ((array).at[(array).len] = val, (array).len++) \
(int)((array).len < (array).cap ? ((array).at[(array).len] = val, (array).len++) \
: (array_reserve(array, ((array).cap + 1)) < 0 ? -1 \
: ((array).at[(array).len] = val, (array).len++))
: ((array).at[(array).len] = val, (array).len++)))
/**
* Pop value from the end of the array.
......@@ -143,7 +143,7 @@ static inline void array_std_free(void *baton, void *p)
* @return 0 on success, <0 on failure
*/
#define array_del(array, i) \
(i) < (array).len ? ((array).len -= 1,(array).at[i] = (array).at[(array).len], 0) : -1
(int)((i) < (array).len ? ((array).len -= 1,(array).at[i] = (array).at[(array).len], 0) : -1)
/**
* Return last element of the array.
......
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