From 06ce5367aa0578b11890db45a9acee3ec4357f58 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Fri, 24 Dec 2010 00:01:34 -0500 Subject: Initialize simple buffer Allocating simple buffer is not enough. It needs to be initialized with something. The patch does exactly this for the case when the empty comment string is represented by a NULL value in the function input variable. Coverity issue 10073. --- ini/ini_comment.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ini/ini_comment.c') diff --git a/ini/ini_comment.c b/ini/ini_comment.c index 2b83ec5..ea9ff5e 100644 --- a/ini/ini_comment.c +++ b/ini/ini_comment.c @@ -300,18 +300,23 @@ static int ini_comment_modify(struct ini_comment *ic, if (length == 0) input_len = strlen(input); else input_len = length; + error = simplebuffer_add_str(elem, + input, + input_len, + INI_COMMENT_LEN); + } + else { + error = simplebuffer_add_str(elem, + "", + 0, + INI_COMMENT_LEN); } - error = simplebuffer_add_str(elem, - input, - input_len, - INI_COMMENT_LEN); if (error) { TRACE_ERROR_NUMBER("Allocate buffer for the comment", error); simplebuffer_free(elem); return error; } - } /* Do action depending on mode */ -- cgit