projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1208 from jy2wong/master
[collectd.git]
/
src
/
daemon
/
common.c
diff --git
a/src/daemon/common.c
b/src/daemon/common.c
index
dfaa61a
..
7b7353d
100644
(file)
--- a/
src/daemon/common.c
+++ b/
src/daemon/common.c
@@
-115,10
+115,9
@@
char *ssnprintf_alloc (char const *format, ...) /* {{{ */
return (strdup (static_buffer));
/* Allocate a buffer large enough to hold the string. */
return (strdup (static_buffer));
/* Allocate a buffer large enough to hold the string. */
- alloc_buffer =
malloc (
alloc_buffer_size);
+ alloc_buffer =
calloc (1,
alloc_buffer_size);
if (alloc_buffer == NULL)
return (NULL);
if (alloc_buffer == NULL)
return (NULL);
- memset (alloc_buffer, 0, alloc_buffer_size);
/* Print again into this new buffer. */
va_start (ap, format);
/* Print again into this new buffer. */
va_start (ap, format);
@@
-144,7
+143,7
@@
char *sstrdup (const char *s)
/* Do not use `strdup' here, because it's not specified in POSIX. It's
* ``only'' an XSI extension. */
sz = strlen (s) + 1;
/* Do not use `strdup' here, because it's not specified in POSIX. It's
* ``only'' an XSI extension. */
sz = strlen (s) + 1;
- r =
(char *) malloc (sizeof (char) *
sz);
+ r =
malloc (
sz);
if (r == NULL)
{
ERROR ("sstrdup: Out of memory.");
if (r == NULL)
{
ERROR ("sstrdup: Out of memory.");
@@
-409,10
+408,9
@@
int escape_string (char *buffer, size_t buffer_size)
if (buffer_size < 3)
return (EINVAL);
if (buffer_size < 3)
return (EINVAL);
- temp =
(char *) malloc (
buffer_size);
+ temp =
calloc (1,
buffer_size);
if (temp == NULL)
return (ENOMEM);
if (temp == NULL)
return (ENOMEM);
- memset (temp, 0, buffer_size);
temp[0] = '"';
j = 1;
temp[0] = '"';
j = 1;
@@
-1169,6
+1167,9
@@
int parse_values (char *buffer, value_list_t *vl, const data_set_t *ds)
char *ptr;
char *saveptr;
char *ptr;
char *saveptr;
+ if ((buffer == NULL) || (vl == NULL) || (ds == NULL))
+ return EINVAL;
+
i = 0;
dummy = buffer;
saveptr = NULL;
i = 0;
dummy = buffer;
saveptr = NULL;