Revision: 1276
http://geeqie.svn.sourceforge.net/geeqie/?rev=1276&view=rev
Author: zas_
Date: 2008-11-26 20:39:50 +0000 (Wed, 26 Nov 2008)
Log Message:
-----------
Handle return values better to silent some warnings.
Modified Paths:
--------------
trunk/src/thumb.c
Modified: trunk/src/thumb.c
===================================================================
--- trunk/src/thumb.c 2008-11-26 20:38:47 UTC (rev 1275)
+++ trunk/src/thumb.c 2008-11-26 20:39:50 UTC (rev 1276)
@@ -573,33 +573,32 @@
{
FILE *file;
gchar buffer[XV_BUFFER];
- guchar *data;
- gint width, height, depth;
+ guchar *data = NULL;
file = fopen(filename, "rt");
if (!file) return NULL;
- fgets(buffer, XV_BUFFER, file);
- if (strncmp(buffer, "P7 332", 6) != 0)
+ if (fgets(buffer, XV_BUFFER, file) != NULL
+ && strncmp(buffer, "P7 332", 6) == 0)
{
- fclose(file);
- return NULL;
- }
+ gint width, height, depth;
- while (fgets(buffer, XV_BUFFER, file) && buffer[0] == '#') /*
do_nothing() */;
+ while (fgets(buffer, XV_BUFFER, file) && buffer[0] == '#') /*
do_nothing() */;
- if (sscanf(buffer, "%d %d %d", &width, &height, &depth) != 3)
- {
- fclose(file);
- return NULL;
+ if (sscanf(buffer, "%d %d %d", &width, &height, &depth) == 3)
+ {
+ gsize size = width * height;
+
+ data = g_new(guchar, size);
+ if (data && fread(data, 1, size, file) == size)
+ {
+ *widthp = width;
+ *heightp = height;
+ }
+ }
}
- data = g_new(guchar, width * height);
- fread(data, 1, width * height, file);
-
fclose(file);
- *widthp = width;
- *heightp = height;
return data;
}
#undef XV_BUFFER
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn