summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/base/ftsystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/base/ftsystem.c')
-rw-r--r--src/3rdparty/freetype/src/base/ftsystem.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/3rdparty/freetype/src/base/ftsystem.c b/src/3rdparty/freetype/src/base/ftsystem.c
index 3013cbda9d..61c99e3635 100644
--- a/src/3rdparty/freetype/src/base/ftsystem.c
+++ b/src/3rdparty/freetype/src/base/ftsystem.c
@@ -4,7 +4,7 @@
*
* ANSI-specific FreeType low-level system interface (body).
*
- * Copyright (C) 1996-2020 by
+ * Copyright (C) 1996-2023 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
@@ -206,7 +206,7 @@
* The number of bytes to read from the stream.
*
* @Return:
- * The number of bytes actually read. If `count' is zero (this is,
+ * The number of bytes actually read. If `count' is zero (that is,
* the function is used for seeking), a non-zero return value
* indicates an error.
*/
@@ -219,7 +219,7 @@
FT_FILE* file;
- if ( !count && offset > stream->size )
+ if ( offset > stream->size && !count )
return 1;
file = STREAM_FILE( stream );
@@ -227,6 +227,11 @@
if ( stream->pos != offset )
ft_fseek( file, (long)offset, SEEK_SET );
+ /* Avoid calling `fread` with `buffer=NULL` and `count=0`, */
+ /* which is undefined behaviour. */
+ if ( !count )
+ return 0;
+
return (unsigned long)ft_fread( buffer, 1, count, file );
}
@@ -275,7 +280,7 @@
stream->close = ft_ansi_stream_close;
FT_TRACE1(( "FT_Stream_Open:" ));
- FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
+ FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n",
filepathname, stream->size ));
return FT_Err_Ok;