chiark / gitweb /
shared: conf-parser
authorTom Gundersen <teg@jklm.no>
Wed, 17 Sep 2014 20:17:53 +0000 (22:17 +0200)
committerTom Gundersen <teg@jklm.no>
Wed, 17 Sep 2014 20:19:53 +0000 (22:19 +0200)
Check memory allocation. Found by Coverity.

Fixes CID #1237644.

src/shared/conf-parser.h

index a17dde90699b8e5814cc7c2d52e0912b963aa5aa..94185152cdecda1eb519925673d0c42d435c7cd0 100644 (file)
@@ -179,6 +179,9 @@ int log_syntax_internal(const char *unit, int level,
                 assert(data);                                                  \
                                                                                \
                 xs = new0(type, 1);                                            \
+                if(!xs)                                                        \
+                        return -ENOMEM;                                        \
+                                                                               \
                 *xs = invalid;                                                 \
                                                                                \
                 FOREACH_WORD(word, l, rvalue, state) {                         \
@@ -211,6 +214,7 @@ int log_syntax_internal(const char *unit, int level,
                         xs = realloc(xs, (++i + 1) * sizeof(type));            \
                         if (!xs)                                               \
                                 return -ENOMEM;                                \
+                                                                               \
                         *(xs + i) = invalid;                                   \
                 }                                                              \
                                                                                \