src/lib/image.c
changeset 69 1d188aa94aee
parent 64 98d934a9b3db
child 177 b2768f3982f3
--- a/src/lib/image.c	Mon Jan 25 02:39:28 2010 +0200
+++ b/src/lib/image.c	Mon Jan 25 02:40:19 2010 +0200
@@ -56,7 +56,13 @@
     char cache_path[1024];
     int err;
 
-    // XXX: verify that the path exists and looks like a PNG file
+    // verify that the path exists and looks like a PNG file
+    if ((err = pt_png_check(path)) < 0)
+        return err;
+    
+    if (err)
+        // fail, not a PNG
+        RETURN_ERROR(PT_ERR_IMG_FORMAT);
 
     // alloc
     if ((err = pt_image_new(&image, ctx, path)))
@@ -87,7 +93,7 @@
     
     // open
     if ((fp = fopen(image->path, "rb")) == NULL)
-        RETURN_ERROR(PT_ERR_IMG_FOPEN);
+        RETURN_ERROR(PT_ERR_IMG_OPEN);
 
     // ok
     *file_ptr = fp;