Fix a few bugs with the new data interface
There were some possibilities of NULL pointer dereferencing. Also, changed one small function to inline.
This commit is contained in:
parent
7e58fecc86
commit
197c0b1fdd
@ -309,9 +309,11 @@ void obs_data_erase(obs_data_t data, const char *name)
|
|||||||
{
|
{
|
||||||
struct obs_data_item *item = get_item(data, name);
|
struct obs_data_item *item = get_item(data, name);
|
||||||
|
|
||||||
|
if (item) {
|
||||||
obs_data_item_detach(item);
|
obs_data_item_detach(item);
|
||||||
obs_data_item_release(&item);
|
obs_data_item_release(&item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void obs_data_setstring(obs_data_t data, const char *name, const char *val)
|
void obs_data_setstring(obs_data_t data, const char *name, const char *val)
|
||||||
{
|
{
|
||||||
@ -405,7 +407,7 @@ int obs_data_array_addref(obs_data_array_t array)
|
|||||||
return ++array->ref;
|
return ++array->ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void obs_data_array_destroy(obs_data_array_t array)
|
static inline void obs_data_array_destroy(obs_data_array_t array)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < array->objects.num; i++)
|
for (size_t i = 0; i < array->objects.num; i++)
|
||||||
obs_data_release(array->objects.array[i]);
|
obs_data_release(array->objects.array[i]);
|
||||||
@ -514,6 +516,7 @@ enum obs_data_type obs_data_item_gettype(obs_data_item_t item)
|
|||||||
|
|
||||||
void obs_data_item_setstring(obs_data_item_t *item, const char *val)
|
void obs_data_item_setstring(obs_data_item_t *item, const char *val)
|
||||||
{
|
{
|
||||||
|
if (!val) val = "";
|
||||||
obs_data_item_setdata(item, val, strlen(val)+1, OBS_DATA_STRING);
|
obs_data_item_setdata(item, val, strlen(val)+1, OBS_DATA_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user