Werner Lemberg pushed to branch master at FreeType / FreeType
Commits:
-
3f2ac7d8
by Tamir Duberstein at 2023-02-25T05:20:57+01:00
1 changed file:
Changes:
... | ... | @@ -219,7 +219,7 @@ |
219 | 219 | FT_FILE* file;
|
220 | 220 | |
221 | 221 | |
222 | - if ( !count && offset > stream->size )
|
|
222 | + if ( offset > stream->size && !count )
|
|
223 | 223 | return 1;
|
224 | 224 | |
225 | 225 | file = STREAM_FILE( stream );
|
... | ... | @@ -227,6 +227,11 @@ |
227 | 227 | if ( stream->pos != offset )
|
228 | 228 | ft_fseek( file, (long)offset, SEEK_SET );
|
229 | 229 | |
230 | + /* Avoid calling `fread` with `buffer=NULL` and `count=0`, */
|
|
231 | + /* which is undefined behaviour. */
|
|
232 | + if ( !count )
|
|
233 | + return 0;
|
|
234 | + |
|
230 | 235 | return (unsigned long)ft_fread( buffer, 1, count, file );
|
231 | 236 | }
|
232 | 237 |