summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-12-24 00:01:34 -0500
committerStephen Gallagher <sgallagh@redhat.com>2011-01-03 13:51:37 -0500
commit06ce5367aa0578b11890db45a9acee3ec4357f58 (patch)
tree56e9de917795a494308fcb6020c74ceef10a96d0
parenta2a434d8a0d97419ac81643602613595105ae24f (diff)
downloadding-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.
-rw-r--r--ini/ini_comment.c15
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 */