Skip to content

Commit ae22678

Browse files
committed
Fix q_remove function for memory leak
For the previous version of the function, when the input char pointer is NULL the function will return NULL. Change the return of the function to the correct pointer. Change-Id: I09fed262bb2e364a92dc9c30a6f4a917e2c0ad68
1 parent 31438b2 commit ae22678

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

queue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ element_t *q_remove_head(struct list_head *head, char *sp, size_t bufsize)
9898
list_del(&first->list);
9999

100100
if (!sp) {
101-
return NULL;
101+
return first;
102102
}
103103

104104
size_t len = strlen(first->value);
@@ -121,7 +121,7 @@ element_t *q_remove_tail(struct list_head *head, char *sp, size_t bufsize)
121121
list_del(&tail->list);
122122

123123
if (!sp) {
124-
return NULL;
124+
return tail;
125125
}
126126

127127
size_t len = strlen(tail->value);

0 commit comments

Comments
 (0)