0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

libobs/util: Fix fread_utf8 not working with files < 3 bytes

When it was checking for the BOM at the beginning of the file, it would
just return out of the function if it didn't read at least 3 bytes.
This would particularly affect text sources.
This commit is contained in:
jp9000 2016-09-28 01:56:29 -07:00
parent 071ed465cb
commit 8b877f7c36

View File

@ -164,7 +164,6 @@ size_t os_fread_mbs(FILE *file, char **pstr)
size_t os_fread_utf8(FILE *file, char **pstr)
{
size_t size = 0;
size_t size_read;
size_t len = 0;
*pstr = NULL;
@ -177,11 +176,13 @@ size_t os_fread_utf8(FILE *file, char **pstr)
char *utf8str;
off_t offset;
bom[0] = 0;
bom[1] = 0;
bom[2] = 0;
/* remove the ghastly BOM if present */
fseek(file, 0, SEEK_SET);
size_read = fread(bom, 1, 3, file);
if (size_read != 3)
return 0;
fread(bom, 1, 3, file);
offset = (astrcmp_n(bom, "\xEF\xBB\xBF", 3) == 0) ? 3 : 0;