Fix some memory leaks when appending data to a message. Scary, horrible, traumatizing memory leaks. Actually it's pretty bad, though, so new release coming up soon. This fixes bug #112.

This commit is contained in:
Christian Hammond 2007-02-15 10:10:32 +00:00
parent f482d2ef94
commit 89d870259f
2 changed files with 26 additions and 37 deletions

View File

@ -1,3 +1,10 @@
Thu Feb 15 02:06:11 PST 2007 Christian Hammond <chipx86@chipx86.com>
* libnotify/notification.c:
- Fix some memory leaks when appending data to a message. Scary,
horrible, traumatizing memory leaks. Actually it's pretty bad,
though, so new release coming up soon. This fixes bug #112.
Thu Feb 15 01:58:52 PST 2007 Christian Hammond <chipx86@chipx86.com> Thu Feb 15 01:58:52 PST 2007 Christian Hammond <chipx86@chipx86.com>
* tests/test-image.c: * tests/test-image.c:

View File

@ -856,60 +856,42 @@ notify_notification_set_urgency(NotifyNotification *notification,
} }
#if CHECK_DBUS_VERSION(0, 60) #if CHECK_DBUS_VERSION(0, 60)
static gboolean static void
_gvalue_array_append_int(GValueArray *array, gint i) _gvalue_array_append_int(GValueArray *array, gint i)
{ {
GValue *value = g_new0(GValue, 1); GValue value = {0};
if (value == NULL) g_value_init(&value, G_TYPE_INT);
return FALSE; g_value_set_int(&value, i);
g_value_array_append(array, &value);
g_value_init(value, G_TYPE_INT); g_value_unset(&value);
g_value_set_int(value, i);
g_value_array_append(array, value);
return TRUE;
} }
static gboolean static void
_gvalue_array_append_bool(GValueArray *array, gboolean b) _gvalue_array_append_bool(GValueArray *array, gboolean b)
{ {
GValue *value = g_new0(GValue, 1); GValue value = {0};
if (value == NULL) g_value_init(&value, G_TYPE_BOOLEAN);
return FALSE; g_value_set_boolean(&value, b);
g_value_array_append(array, &value);
g_value_init(value, G_TYPE_BOOLEAN); g_value_unset(&value);
g_value_set_boolean(value, b);
g_value_array_append(array, value);
return TRUE;
} }
static gboolean static void
_gvalue_array_append_byte_array(GValueArray *array, guchar *bytes, gsize len) _gvalue_array_append_byte_array(GValueArray *array, guchar *bytes, gsize len)
{ {
GArray *byte_array; GArray *byte_array;
GValue *value; GValue value = {0};
byte_array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), len); byte_array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), len);
g_assert(byte_array != NULL);
if (byte_array == NULL)
return FALSE;
byte_array = g_array_append_vals(byte_array, bytes, len); byte_array = g_array_append_vals(byte_array, bytes, len);
if ((value = g_new0(GValue, 1)) == NULL) g_value_init(&value, DBUS_TYPE_G_UCHAR_ARRAY);
{ g_value_set_boxed_take_ownership(&value, byte_array);
g_array_free(byte_array, TRUE); g_value_array_append(array, &value);
return FALSE; g_value_unset(&value);
}
g_value_init(value, DBUS_TYPE_G_UCHAR_ARRAY);
g_value_set_boxed_take_ownership(value, byte_array);
g_value_array_append(array, value);
return TRUE;
} }
#endif /* D-BUS >= 0.60 */ #endif /* D-BUS >= 0.60 */