Skip to content

Commit 0bf22b8

Browse files
chipitsinewtarreau
authored andcommitted
CLEANUP: admin/halog: improve handling of memory allocation errors
Found via cppcheck --force --enable=all --output-file=haproxy.log : admin/halog/halog.c:1805:2: warning: If memory allocation fails, then there is a possible null pointer dereference: ustat [nullPointerOutOfMemory] admin/halog/halog.c:1806:2: warning: If memory allocation fails, then there is a possible null pointer dereference: ustat [nullPointerOutOfMemory] admin/halog/halog.c:1809:2: warning: If memory allocation fails, then there is a possible null pointer dereference: ustat [nullPointerOutOfMemory] admin/halog/halog.c:1810:2: warning: If memory allocation fails, then there is a possible null pointer dereference: ustat [nullPointerOutOfMemory] admin/halog/halog.c:1814:2: warning: If memory allocation fails, then there is a possible null pointer dereference: ustat [nullPointerOutOfMemory]
1 parent c1d6973 commit 0bf22b8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

admin/halog/halog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,8 @@ void filter_count_ip(const char *source_field, const char *accept_field, const c
18011801
*/
18021802
if (unlikely(!ustat))
18031803
ustat = calloc(1, sizeof(*ustat));
1804+
if (!ustat)
1805+
return;
18041806

18051807
ustat->nb_err = err;
18061808
ustat->nb_req = 1;

0 commit comments

Comments
 (0)