Browse Source

libobs/util: Make sure to set capacity in dstr_ncopy* funcs

jp9000 9 years ago
parent
commit
ae8b4bc538
1 changed files with 2 additions and 0 deletions
  1. 2 0
      libobs/util/dstr.c

+ 2 - 0
libobs/util/dstr.c

@@ -346,6 +346,7 @@ void dstr_ncopy(struct dstr *dst, const char *array, const size_t len)
 
 	dst->array = bmemdup(array, len + 1);
 	dst->len   = len;
+	dst->capacity = len + 1;
 
 	dst->array[len] = 0;
 }
@@ -363,6 +364,7 @@ void dstr_ncopy_dstr(struct dstr *dst, const struct dstr *str, const size_t len)
 	newlen = size_min(len, str->len);
 	dst->array = bmemdup(str->array, newlen + 1);
 	dst->len   = newlen;
+	dst->capacity = newlen + 1;
 
 	dst->array[newlen] = 0;
 }