mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-10-23 14:28:51 -04:00
libobs/util: Fix possible null pointer dereference
Never checks to see whether the source dstr is empty before copying, and will crash if empty.
This commit is contained in:
1 parent
d193a7d547
commit
a576439f22
1 file changed
+5
-3
+5
-3
@@ -237,9 +237,11 @@ static inline void dstr_copy_dstr(struct dstr *dst, const struct dstr *src)
|
||||
if (dst->array)
|
||||
dstr_free(dst);
|
||||
|
||||
dstr_ensure_capacity(dst, src->len + 1);
|
||||
memcpy(dst->array, src->array, src->len + 1);
|
||||
dst->len = src->len;
|
||||
if (src->len) {
|
||||
dstr_ensure_capacity(dst, src->len + 1);
|
||||
memcpy(dst->array, src->array, src->len + 1);
|
||||
dst->len = src->len;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void dstr_reserve(struct dstr *dst, const size_t capacity)
|
||||
|
||||
Reference in new issue
Block a user