libobs/util: Prevent null pointer deref with dstr_cmp

This makes it prevent any null pointer dereferences, and makes it
consistent with the other dstr compare functions.
This commit is contained in:
Lain
2024-10-05 16:49:23 -07:00
parent cc36ccd07d
commit 089ba29961
+3 -1
View File
@@ -287,7 +287,9 @@ static inline const char *dstr_find(const struct dstr *str, const char *find)
static inline int dstr_cmp(const struct dstr *str1, const char *str2)
{
return strcmp(str1->array, str2);
const char *s1 = str1->array ? str1->array : "";
const char *s2 = str2 ? str2 : "";
return strcmp(s1, s2);
}
static inline int dstr_cmpi(const struct dstr *str1, const char *str2)