text-freetype2: Fix incorrect fread argument order

This fixes UTF-16 BOM files being loaded incorrectly and having their
newlines parsed incorrectly in read from end mode. Detected by PVS
Studio.
master
Richard Stanway 2022-01-17 23:32:36 +01:00
parent a3e3ee8a8b
commit 1af1a432e2
1 changed files with 3 additions and 3 deletions

View File

@ -437,7 +437,7 @@ void load_text_from_file(struct ft2_source *srcdata, const char *filename)
fseek(tmp_file, 0, SEEK_END);
filesize = (uint32_t)ftell(tmp_file);
fseek(tmp_file, 0, SEEK_SET);
bytes_read = fread(&header, 2, 1, tmp_file);
bytes_read = fread(&header, 1, 2, tmp_file);
if (bytes_read == 2 && header == 0xFEFF) {
// File is already in UTF-16 format
@ -491,7 +491,7 @@ void read_from_end(struct ft2_source *srcdata, const char *filename)
}
return;
}
bytes_read = fread(&value, 2, 1, tmp_file);
bytes_read = fread(&value, 1, 2, tmp_file);
if (bytes_read == 2 && value == 0xFEFF)
utf16 = true;
@ -513,7 +513,7 @@ void read_from_end(struct ft2_source *srcdata, const char *filename)
if (bytes_read == 1 && bvalue == '\n')
line_breaks++;
} else {
bytes_read = fread(&value, 2, 1, tmp_file);
bytes_read = fread(&value, 1, 2, tmp_file);
if (bytes_read == 2 && value == L'\n')
line_breaks++;
}