From: Tom Gundersen Date: Wed, 17 Sep 2014 20:17:53 +0000 (+0200) Subject: shared: conf-parser X-Git-Tag: v217~536 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=83e341a637b75f7f592a5dc717c34d8b67ed4ffa;hp=19c784c414e6f2b35a268034905e1db226e905f6;p=elogind.git shared: conf-parser Check memory allocation. Found by Coverity. Fixes CID #1237644. --- diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index a17dde906..94185152c 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -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; \ } \ \