]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: admin/halog: improve handling of memory allocation errors
authorIlia Shipitsin <chipitsine@gmail.com>
Sun, 31 May 2026 07:19:21 +0000 (09:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 31 May 2026 08:30:00 +0000 (10:30 +0200)
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]

admin/halog/halog.c

index 5b6296033f1a816882ffa5162b7c237d98a6ed17..52986849f3b97bd32a0b53d6c395cd25e7d79d81 100644 (file)
@@ -1801,6 +1801,8 @@ void filter_count_ip(const char *source_field, const char *accept_field, const c
         */
        if (unlikely(!ustat))
                ustat = calloc(1, sizeof(*ustat));
+       if (!ustat)
+               return;
 
        ustat->nb_err = err;
        ustat->nb_req = 1;