summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fe4af1c)
raw | patch | inline | side by side (parent: fe4af1c)
author | Igor Peshansky <igorpeshansky@github.com> | |
Mon, 12 Sep 2016 17:07:52 +0000 (13:07 -0400) | ||
committer | Igor Peshansky <igorpeshansky@github.com> | |
Mon, 12 Sep 2016 18:05:35 +0000 (14:05 -0400) |
- Locking fixes,
- Leak fixes.
- Leak fixes.
src/daemon/meta_data.c | patch | blob | history | |
src/target_set.c | patch | blob | history |
diff --git a/src/daemon/meta_data.c b/src/daemon/meta_data.c
index d26570e9db7f3e855f347b4303441041a912ba15..a11fccb2e2fb125b02ffc9d8d048ad58f3388972 100644 (file)
--- a/src/daemon/meta_data.c
+++ b/src/daemon/meta_data.c
char *actual;
char buffer[MD_MAX_NONSTRING_CHARS]; /* For non-string types. */
char *temp;
+ int type;
if ((md == NULL) || (key == NULL) || (value == NULL))
return (-EINVAL);
return (-ENOENT);
}
- switch (e->type)
+ type = e->type;
+
+ switch (type)
{
case MD_TYPE_STRING:
actual = e->value.mv_string;
break;
default:
pthread_mutex_unlock (&md->lock);
- ERROR ("meta_data_as_string: unknown type %d for key `%s'",
- e->type, e->key);
+ ERROR ("meta_data_as_string: unknown type %d for key `%s'", type, key);
return (-ENOENT);
}
+ pthread_mutex_unlock (&md->lock);
+
temp = md_strdup (actual);
if (temp == NULL)
{
pthread_mutex_unlock (&md->lock);
- ERROR ("meta_data_as_string: md_strdup failed for key `%s'.", e->key);
+ ERROR ("meta_data_as_string: md_strdup failed for key `%s'.", key);
return (-ENOMEM);
}
- pthread_mutex_unlock (&md->lock);
-
*value = temp;
return (0);
diff --git a/src/target_set.c b/src/target_set.c
index 95f03173eede11176983907205f9c18587568513..3de86e4840c94cf3e384e8f4fddd9c61a7b51837 100644 (file)
--- a/src/target_set.c
+++ b/src/target_set.c
if (l == NULL)
return;
- free (l->key);
+ sfree (l->key);
if (l->next != NULL)
ts_key_list_free (l->next);
- free (l);
+ sfree (l);
} /* }}} void ts_name_list_free */
struct ts_data_s
}
if (cf_util_get_string (ci, &entry->key) != 0)
+ {
+ ts_key_list_free (entry);
return (-1); /* An error has already been reported. */
+ }
if (strlen (entry->key) == 0)
{
ERROR ("Target `set': The `%s' option does not accept empty string as "
"first argument.", ci->key);
- sfree (entry->key);
+ ts_key_list_free (entry);
return (-1);
}