Commits

Oleg Oshmyan  committed bb2334d

Fixed a buffer overflow on Win32 sometimes resulting in a crash

  • Participants
  • Parent commits fb50c6f

Comments (0)

Files changed (1)

File src/util.cpp

 	unsigned char* utf16_conversion = (unsigned char*)malloc( sizeof(unsigned char)* string_length * 2 );
 	memset(utf16_conversion, 0, string_length * 2 );
 			
-	int utf_16_glyphs = UTF8ToUTF16BE(utf16_conversion, char_glyphs * 2, (unsigned char*)input_utf8, string_length);
+	int utf_16_glyphs = UTF8ToUTF16BE(utf16_conversion, char_glyphs * 2, (unsigned char*)input_utf8, string_length) / 2; //returned value is in bytes
 	return_val = Convert_multibyteUTF16_to_wchar((char*)utf16_conversion, (size_t)utf_16_glyphs, false );
 	free(utf16_conversion); utf16_conversion=NULL;
 	return (return_val);