[vlc-commits] dbus: Add missing memory allocation failure handling

Mirsal Ennaime git at videolan.org
Tue Feb 5 13:37:30 CET 2013


vlc | branch: master | Mirsal Ennaime <mirsal at videolan.org> | Fri Feb  1 18:25:45 2013 +0100| [018ea797875b5f61c208f2845615460bc39c146c] | committer: Mirsal Ennaime

dbus: Add missing memory allocation failure handling

Handle memory allocation failures when sending the PropertyChanged
signal in the TrackList interface implementation.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=018ea797875b5f61c208f2845615460bc39c146c
---

 modules/control/dbus/dbus_tracklist.c |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/modules/control/dbus/dbus_tracklist.c b/modules/control/dbus/dbus_tracklist.c
index 7c02cc3..353919d 100644
--- a/modules/control/dbus/dbus_tracklist.c
+++ b/modules/control/dbus/dbus_tracklist.c
@@ -496,17 +496,29 @@ PropertiesChangedSignal( intf_thread_t    *p_intf,
 
     OUT_ARGUMENTS;
     ADD_STRING( &psz_interface_name );
-    dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}",
-                                      &changed_properties );
 
-    dbus_message_iter_close_container( &args, &changed_properties );
+    if( unlikely(!dbus_message_iter_open_container( &args,
+                                                    DBUS_TYPE_ARRAY, "{sv}",
+                                                    &changed_properties )) )
+        return DBUS_HANDLER_RESULT_NEED_MEMORY;
 
-    dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "s",
-                                      &invalidated_properties );
+    if( unlikely(!dbus_message_iter_close_container( &args,
+                                                     &changed_properties )) )
+        return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+    if( unlikely(!dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "s",
+                                                    &invalidated_properties )) )
+        return DBUS_HANDLER_RESULT_NEED_MEMORY;
 
     i_properties    = vlc_dictionary_keys_count( p_changed_properties );
     ppsz_properties = vlc_dictionary_all_keys( p_changed_properties );
 
+    if( unlikely(!ppsz_properties) )
+    {
+        dbus_message_iter_abandon_container( &args, &invalidated_properties );
+        return DBUS_HANDLER_RESULT_NEED_MEMORY;
+    }
+
     for( int i = 0; i < i_properties; i++ )
     {
         if( !strcmp( ppsz_properties[i], "Tracks" ) )
@@ -517,9 +529,12 @@ PropertiesChangedSignal( intf_thread_t    *p_intf,
         free( ppsz_properties[i] );
     }
 
-    dbus_message_iter_close_container( &args, &invalidated_properties );
     free( ppsz_properties );
 
+    if( unlikely(!dbus_message_iter_close_container( &args,
+                    &invalidated_properties )) )
+        return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
     SIGNAL_SEND;
 }
 



More information about the vlc-commits mailing list