[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 04cff37: Minor `fread' coding issues.
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master 04cff37: Minor `fread' coding issues. |
Date: |
Wed, 24 May 2017 07:24:05 -0400 (EDT) |
branch: master
commit 04cff3770138fa273e115daa0dd12a4caa016199
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
Minor `fread' coding issues.
* src/ftbench.c (get_face), src/ftcommon.c (FTDemo_Install_Font):
Make `nmemb' argument of `fread' equal 1; this allows a
simplification of the return value test (you get either 0 or 1).
* src/ftdiff.c (main): Handle `fread' errors.
Problem reported by Kushal K S V S (కుషల్ కే ఎస్ వీ ఎస్)
<address@hidden>.
---
ChangeLog | 12 ++++++++++++
src/ftbench.c | 2 +-
src/ftcommon.c | 2 +-
src/ftdiff.c | 11 ++++++++---
4 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 452236a..ff82e61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2017-05-24 Werner Lemberg <address@hidden>
+
+ Minor `fread' coding issues.
+
+ * src/ftbench.c (get_face), src/ftcommon.c (FTDemo_Install_Font):
+ Make `nmemb' argument of `fread' equal 1; this allows a
+ simplification of the return value test (you get either 0 or 1).
+
+ * src/ftdiff.c (main): Handle `fread' errors.
+ Problem reported by Kushal K S V S (కుషల్ కే ఎస్ వీ ఎస్)
+ <address@hidden>.
+
2017-05-18 Alexei Podtelezhnikov <address@hidden>
[ftgrid, ftstring, ftview] Unify top header lines.
diff --git a/src/ftbench.c b/src/ftbench.c
index 3535bb3..f6ec4e6 100644
--- a/src/ftbench.c
+++ b/src/ftbench.c
@@ -717,7 +717,7 @@
return 1;
}
- if ( fread( memory_file, 1, memory_size, file ) != memory_size )
+ if ( !fread( memory_file, memory_size, 1, file ) )
{
fprintf( stderr, "read error\n" );
free( memory_file );
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 11fef65..0ba81ad 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -466,7 +466,7 @@
return FT_Err_Out_Of_Memory;
}
- if ( fread( font->file_address, 1, file_size, file ) != file_size )
+ if ( !fread( font->file_address, file_size, 1, file ) )
{
free( font->file_address );
free( font );
diff --git a/src/ftdiff.c b/src/ftdiff.c
index 15a2228..adf822a 100644
--- a/src/ftdiff.c
+++ b/src/ftdiff.c
@@ -1550,10 +1550,15 @@
fseek( tfile, 0, SEEK_SET );
text = (char*)malloc( (unsigned int)( tsize + 1 ) );
- if ( text != NULL )
+ if ( text )
{
- fread( text, (unsigned int)tsize, 1, tfile );
- text[tsize] = 0;
+ if ( !fread( text, (unsigned int)tsize, 1, tfile ) )
+ {
+ fprintf( stderr, "read error\n" );
+ text = (char *)default_text;
+ }
+ else
+ text[tsize] = '\0';
}
else
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 04cff37: Minor `fread' coding issues.,
Werner LEMBERG <=