Pārlūkot izejas kodu

libobs: Make wcs<->utf8 conversion consistent

On Windows NULL characters would be included in the output if insize is
non-zero, but on *nix it would abort on the first NULL.
derrod 3 gadi atpakaļ
vecāks
revīzija
a5468cfee0
1 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  1. 2 2
      libobs/util/utf8.c

+ 2 - 2
libobs/util/utf8.c

@@ -146,7 +146,7 @@ size_t utf8_to_wchar(const char *in, size_t insize, wchar_t *out,
 	wlim = out == NULL ? NULL : out + outsize;
 	wlim = out == NULL ? NULL : out + outsize;
 
 
 	for (; p < lim; p += n) {
 	for (; p < lim; p += n) {
-		if (!*p)
+		if (!*p && insize == 0)
 			break;
 			break;
 
 
 		if (utf8_forbidden(*p) != 0 && (flags & UTF8_IGNORE_ERROR) == 0)
 		if (utf8_forbidden(*p) != 0 && (flags & UTF8_IGNORE_ERROR) == 0)
@@ -276,7 +276,7 @@ size_t wchar_to_utf8(const wchar_t *in, size_t insize, char *out,
 	total = 0;
 	total = 0;
 
 
 	for (; w < wlim; w++) {
 	for (; w < wlim; w++) {
-		if (!*w)
+		if (!*w && insize == 0)
 			break;
 			break;
 
 
 		if (wchar_forbidden(*w) != 0) {
 		if (wchar_forbidden(*w) != 0) {