2006-08-08 John (J5) Palmieri <johnp@redhat.com>
+ These are all patches from Kjartan Maraas <kmaraas at gnome dot org>
+ with cleanups of bugs found from Coverity reports:
+
+ * dbus/dbus-sysdeps-util.c (_dbus_write_pid_file):
+ close the file on error to avoid a leak
+
+ * bus/expirelist.c (bus_expire_list_test):
+ Check for NULL on dbus_new0
+
+ * bus/activation.c (update_directory):
+ remove dead code
+
+ * bus/config-parser.c (merge_service_context_hash, start_selinux_child):
+ Fix some leaks
+
+ * bus/bus.c (process_config_every_time):
+ Fixed a leak
+
+ * bus/desktop-file.c (parse_key_value):
+ Fixed leak
+
+ * bus/selinux.c (bus_selinux_id_table_insert):
+ Fixed leak
+
+2006-08-08 John (J5) Palmieri <johnp@redhat.com>
+
* dbus/dbus-object-tree.c (_dbus_object_subtree_new):
remove dead code
if (iter != NULL)
_dbus_directory_close (iter);
- if (desktop_file)
- bus_desktop_file_free (desktop_file);
_dbus_string_free (&filename);
_dbus_string_free (&full_path);
{
DBusString full_address;
DBusList *link;
-
+ char *addr;
+
dbus_bool_t retval;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ addr = NULL;
retval = FALSE;
if (!_dbus_string_init (&full_address))
link = _dbus_list_get_last_link (&context->servers);
while (link != NULL)
{
- char *addr;
-
addr = dbus_server_get_address (link->data);
if (addr == NULL)
{
}
dbus_free (addr);
+ addr = NULL;
link = _dbus_list_get_prev_link (&context->servers, link);
}
failed:
_dbus_string_free (&full_address);
+
+ if (addr)
+ dbus_free (addr)
+
return retval;
}
DBusHashTable *from)
{
DBusHashIter iter;
-
+ char *service_copy;
+ char *context_copy;
+
+ service_copy = NULL;
+ context_copy = NULL;
+
_dbus_hash_iter_init (from, &iter);
while (_dbus_hash_iter_next (&iter))
{
const char *service = _dbus_hash_iter_get_string_key (&iter);
const char *context = _dbus_hash_iter_get_value (&iter);
- char *service_copy;
- char *context_copy;
service_copy = _dbus_strdup (service);
if (service_copy == NULL)
- return FALSE;
+ goto fail;
context_copy = _dbus_strdup (context);
if (context_copy == NULL)
- return FALSE;
+ goto fail;
if (!_dbus_hash_table_insert_string (dest, service_copy, context_copy))
- return FALSE;
+ goto fail;
+
+ service_copy = NULL;
+ context_copy = NULL;
}
return TRUE;
+
+ fail:
+ if (service_copy)
+ dbus_free (service_copy);
+
+ if (context_copy)
+ dbus_free (context_copy);
+
+ return FALSE;
}
static dbus_bool_t
const char **attribute_values,
DBusError *error)
{
+ char *own_copy;
+ char *context_copy;
+
+ own_copy = NULL;
+ context_copy = NULL;
+
if (strcmp (element_name, "associate") == 0)
{
const char *own;
const char *context;
- char *own_copy;
- char *context_copy;
if (!locate_attributes (parser, "associate",
attribute_names,
own_copy = _dbus_strdup (own);
if (own_copy == NULL)
- return FALSE;
+ goto oom;
context_copy = _dbus_strdup (context);
if (context_copy == NULL)
- return FALSE;
+ goto oom;
if (!_dbus_hash_table_insert_string (parser->service_context_table,
own_copy, context_copy))
- {
- BUS_SET_OOM (error);
- return FALSE;
- }
-
+ goto oom;
+
return TRUE;
}
else
element_name, "selinux");
return FALSE;
}
+
+ oom:
+ if (own_copy)
+ dbus_free (own_copy);
+
+ if (context_copy)
+ dbus_free (context_copy);
+
+ BUS_SET_OOM (error);
+ return FALSE;
}
dbus_bool_t
line = new_line (parser);
if (line == NULL)
{
+ dbus_free (value);
parser_free (parser);
return FALSE;
}
if (!_dbus_string_init (&key))
{
+ dbus_free (value);
parser_free (parser);
return FALSE;
}
if (!_dbus_string_copy_len (&parser->data, key_start, key_end - key_start,
&key, 0))
{
+ dbus_free (value);
parser_free (parser);
return FALSE;
}
if (!_dbus_string_steal_data (&key, &tmp))
{
+ dbus_free (value);
parser_free (parser);
return FALSE;
}
long tv_sec_past, tv_usec_past;
TestExpireItem *item;
int next_interval;
-
+ dbus_bool_t result = FALSE;
+
+
loop = _dbus_loop_new ();
_dbus_assert (loop != NULL);
item = dbus_new0 (TestExpireItem, 1);
+ if (item == NULL)
+ goto oom;
+
item->item.added_tv_sec = tv_sec;
item->item.added_tv_usec = tv_usec;
if (!_dbus_list_append (&list->items, item))
bus_expire_list_free (list);
_dbus_loop_unref (loop);
- return TRUE;
+ result = TRUE;
+
+ oom:
+ return result;
}
#endif /* DBUS_BUILD_TESTS */
if (avc_context_to_sid ((char *) service_context, &sid) < 0)
{
if (errno == ENOMEM)
- return FALSE;
+ {
+ dbus_free (key);
+ return FALSE;
+ }
+
_dbus_warn ("Error getting SID from context \"%s\": %s\n",
(char *) service_context,
_dbus_strerror (errno));
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to write to \"%s\": %s", cfilename,
_dbus_strerror (errno));
+
+ fclose (f);
return FALSE;
}