Browse Source

libobs: Fix obs_data crash

Accessing objects inside obs_datas after obs_data_clear was called on the
parent obs_data causes a NULL dereference.

Reproduce with:
	obs_data_t *data = obs_data_create();
	obs_data_set_obj(data, "foo", NULL);
	obs_data_clear(data);
	obs_data_get_obj(data, "foo");
Palana 10 years ago
parent
commit
ad5aec99ff
1 changed files with 5 additions and 1 deletions
  1. 5 1
      libobs/obs-data.c

+ 5 - 1
libobs/obs-data.c

@@ -131,7 +131,11 @@ static inline obs_data_t *get_item_obj(struct obs_data_item *item)
 	if (!item)
 		return NULL;
 
-	return *(obs_data_t**)get_item_data(item);
+	obs_data_t **data = get_item_data(item);
+	if (!data)
+		return NULL;
+
+	return *data;
 }
 
 static inline obs_data_t *get_item_default_obj(struct obs_data_item *item)