dbus_message_append_args_valist - abandon container
authorScott James Remnant <scott@ubuntu.com>
Thu, 9 Jul 2009 15:35:13 +0000 (16:35 +0100)
committerScott James Remnant <scott@ubuntu.com>
Thu, 9 Jul 2009 15:35:13 +0000 (16:35 +0100)
In case of OOM when constructing an array, we should abandon the
container to free the resources.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
dbus/dbus-message.c

index 30b5d6c..98c284e 100644 (file)
@@ -1567,8 +1567,10 @@ dbus_message_append_args_valist (DBusMessage *message,
               if (!dbus_message_iter_append_fixed_array (&array,
                                                          element_type,
                                                          value,
-                                                         n_elements))
+                                                         n_elements)) {
+                dbus_message_iter_abandon_container (&iter, &array);
                 goto failed;
+              }
             }
           else if (element_type == DBUS_TYPE_STRING ||
                    element_type == DBUS_TYPE_SIGNATURE ||
@@ -1589,8 +1591,10 @@ dbus_message_append_args_valist (DBusMessage *message,
                 {
                   if (!dbus_message_iter_append_basic (&array,
                                                        element_type,
-                                                       &value[i]))
+                                                       &value[i])) {
+                    dbus_message_iter_abandon_container (&iter, &array);
                     goto failed;
+                  }
                   ++i;
                 }
             }