]> granicus.if.org Git - handbrake/commitdiff
libhb: fix hb_dict_next() when dict is empty
authorjstebbins <jstebbins.hb@gmail.com>
Sun, 9 Dec 2012 19:08:08 +0000 (19:08 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Sun, 9 Dec 2012 19:08:08 +0000 (19:08 +0000)
It would return an invalid entry instead of NULL.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5095 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/hb_dict.c

index 6c4ac86991e3a187ef121acaab3a63657741747a..152cf7feb4a823ebb50be049f78a328a75c11b98 100644 (file)
@@ -145,9 +145,9 @@ hb_dict_entry_t * hb_dict_get( hb_dict_t * dict, const char * key )
 
 hb_dict_entry_t * hb_dict_next( hb_dict_t * dict, hb_dict_entry_t * previous )
 {
-    if( !dict || !dict->objects )
+    if( dict == NULL || dict->objects == NULL || !dict->count )
         return NULL;
-    if( !previous )
+    if( previous == NULL )
         return &dict->objects[0];
     unsigned int prev_index = previous - dict->objects;
     if( prev_index + 1 < dict->count )