[xpcom] Don't leak array signatures
authorKalle Vahlman <kalle.vahlman@movial.com>
Thu, 30 Apr 2009 07:46:27 +0000 (10:46 +0300)
committerKalle Vahlman <kalle.vahlman@movial.com>
Thu, 30 Apr 2009 07:46:59 +0000 (10:46 +0300)
xpcom-dbusservice/DBusMarshaling.cpp

index 02f332df52b108d661fb1b625ee75a1b13b7b64c..ce16c96be8d102d7b3438fcb6cf7927be0c81239 100644 (file)
@@ -465,9 +465,10 @@ addVariantToIter(JSContext* cx, nsIVariant *aVariant, DBusMessageIter *aIter, DB
                         DBusSignatureIter childSigIter;
                         DBusSignatureIter dictSigIter;
                         dbus_signature_iter_recurse(aSigIter, &childSigIter);
+                        char *array_signature = dbus_signature_iter_get_signature(&childSigIter);
                         dbus_message_iter_open_container(aIter, DBUS_TYPE_ARRAY,
-                            dbus_signature_iter_get_signature(&childSigIter),
-                            &childIter);
+                                                         array_signature, &childIter);
+                        dbus_free(array_signature);
 
                         // Skip the dict signature iter to the value type
                         dbus_signature_iter_recurse(&childSigIter, &dictSigIter);
@@ -553,6 +554,7 @@ addVariantToIter(JSContext* cx, nsIVariant *aVariant, DBusMessageIter *aIter, DB
                                                   array_signature, &arrayIter))
             {
                 nsMemory::Free(data_ptr);
+                dbus_free(array_signature);
                 return;
             }
 
@@ -561,6 +563,7 @@ addVariantToIter(JSContext* cx, nsIVariant *aVariant, DBusMessageIter *aIter, DB
 
             dbus_message_iter_close_container(aIter, &arrayIter);
             nsMemory::Free(data_ptr);
+            dbus_free(array_signature);
         }
     }
     else if (element_type == DBUS_TYPE_VARIANT)