mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-10-24 12:03:14 +08:00
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:
+3
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user