diff options
author | Dmitri Pal <dpal@redhat.com> | 2010-12-24 00:01:34 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-01-03 13:51:37 -0500 |
commit | 06ce5367aa0578b11890db45a9acee3ec4357f58 (patch) | |
tree | 56e9de917795a494308fcb6020c74ceef10a96d0 /ini | |
parent | a2a434d8a0d97419ac81643602613595105ae24f (diff) | |
download | ding-libs-06ce5367aa0578b11890db45a9acee3ec4357f58.tar.gz ding-libs-06ce5367aa0578b11890db45a9acee3ec4357f58.tar.xz ding-libs-06ce5367aa0578b11890db45a9acee3ec4357f58.zip |
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.
Diffstat (limited to 'ini')
-rw-r--r-- | ini/ini_comment.c | 15 |
1 files changed, 10 insertions, 5 deletions
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 */ |