adds clean handling in case the stack of dav_exec_expr() runs out of memory

Thu, 31 Aug 2017 13:10:55 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 31 Aug 2017 13:10:55 +0200
changeset 290
1e3e374d9386
parent 289
0f83fe5e2b07
child 291
8828260d2fd8

adds clean handling in case the stack of dav_exec_expr() runs out of memory

libidav/davqlexec.c file | annotate | diff | comparison | revisions
--- a/libidav/davqlexec.c	Thu Aug 31 12:58:06 2017 +0200
+++ b/libidav/davqlexec.c	Thu Aug 31 13:10:55 2017 +0200
@@ -949,7 +949,14 @@
 #define DAVQL_PUSH(obj) \
         if(stpos == stsize) { \
             stsize += 64; \
-            stack = realloc(stack, stsize * sizeof(DavQLStackObj)); \
+            DavQLStackObj *stack_newptr; \
+            stack_newptr = realloc(stack, stsize * sizeof(DavQLStackObj)); \
+            if(stack_newptr) { \
+                stack = stack_newptr; \
+            } else { \
+                free(stack); \
+                return -1; \
+            }\
         } \
         stack[stpos++] = obj;
 #define DAVQL_PUSH_INT(intval) \

mercurial