Few memory leaks were fixed.
First memory leak occurred due to improper linked list construction in `add_to_ptr_list` function. In case if list had tail - result of execution would be lost pointer of previous tail. Second memory leak was in `output_error`. Function allocated `dataset` but never freed allocated memory.
This commit is contained in:
@@ -231,6 +231,7 @@ static inline int output_error(
|
|||||||
dataset[11] = ERL_DRV_TUPLE;
|
dataset[11] = ERL_DRV_TUPLE;
|
||||||
dataset[12] = 2;
|
dataset[12] = 2;
|
||||||
driver_output_term(drv->port, dataset, term_count);
|
driver_output_term(drv->port, dataset, term_count);
|
||||||
|
driver_free(dataset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1313,11 +1314,9 @@ static inline ptr_list *add_to_ptr_list(ptr_list *list, void *value_ptr) {
|
|||||||
new_node->head = value_ptr;
|
new_node->head = value_ptr;
|
||||||
new_node->tail = NULL;
|
new_node->tail = NULL;
|
||||||
if (list) {
|
if (list) {
|
||||||
list->tail = new_node;
|
new_node->tail = list;
|
||||||
return list;
|
|
||||||
} else {
|
|
||||||
return new_node;
|
|
||||||
}
|
}
|
||||||
|
return new_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void free_ptr_list(ptr_list *list, void(* free_head)(void *)) {
|
static inline void free_ptr_list(ptr_list *list, void(* free_head)(void *)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user