From a048b783838b2c7162fa3c9d2ea9a476e7aac850 Mon Sep 17 00:00:00 2001 From: Matthew Vernon Date: Fri, 7 Nov 2025 11:52:59 +0000 Subject: [PATCH] Check fread return status x3 Again, spotted by newer build tools. --- buildcmp.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/buildcmp.c b/buildcmp.c index 9d97788..aef3358 100644 --- a/buildcmp.c +++ b/buildcmp.c @@ -94,10 +94,16 @@ static void put_header(void) strncpy( fh.description, "Compressed Data File", TSL_DESCRSZ ); /* Process the squish statistics */ - fread( &d, sizeof(int), 1, sf ); + if(fread( &d, sizeof(int), 1, sf ) < 1){ + perror("Failed to read Window size from squish.stats"); + exit(1); + } printf( "Window size (bytes): %d\n", d ); univ_assign(fh.wsize, d); - fread( &d, sizeof(int), 1, sf ); + if(fread( &d, sizeof(int), 1, sf ) < 1){ + perror("Failed to read Number of windows from squish.stats"); + exit(1); + } printf( "Number of windows: %d\n", d ); count = d; univ_assign(fh.wnum, d); @@ -110,7 +116,10 @@ static void put_header(void) winx = (Univ_Int *) w_table; for (i=0; i <= count; i++) { - fread( &d, sizeof(int), 1, sf ); + if(fread( &d, sizeof(int), 1, sf ) < 1){ + perror("Failed to read Window start point from squish.stats"); + exit(1); + } univ_assign(*winx++, j=d+headersize); printf( "Window[%d] starts at %d\n", i, j ); } -- 2.30.2