In particular, fix warnings of the form "warning: ignoring return value of
‘char* fgets(char*, int, FILE*)’, declared with attribute warn_unused_result" by
checking return value of fgets.
---
wmcdplay/wmcdplay.cc | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/wmcdplay/wmcdplay.cc b/wmcdplay/wmcdplay.cc
index 0108b89..ab18f4a 100644
--- a/wmcdplay/wmcdplay.cc
+++ b/wmcdplay/wmcdplay.cc
@@ -644,7 +644,10 @@ bool readArtwork(char *artfilen){
char buf[256];
bool done=false;
while(!done){
- fgets(buf, 250, artfile);
+ if (fgets(buf, 250, artfile) == NULL) {
+ fprintf(stderr,"%s : Error reading artwork file.\n", NAME);
+ return false;
+ }
done=(feof(artfile)!=0);
if(!done){
@@ -734,7 +737,10 @@ char *readBlock(FILE *dfile){
long bytes=0;
char *block=NULL;
do{
- fgets(buf, 250, dfile);
+ if (fgets(buf, 250, dfile) == NULL) {
+ fprintf(stderr,"%s : Error reading artwork file.\n", NAME);
+ return NULL;
+ }
int buflen=strlen(buf);
block=(char *)realloc(block, sizeof(char)*(bytes+buflen+1));
strcpy(block+bytes, buf);
--
2.1.0
--
To unsubscribe, send mail to [email protected].