don't badly abort on unreadable files
authorgc <gc>
Sat, 31 May 2008 23:15:57 +0000 (23:15 +0000)
committergc <gc>
Sat, 31 May 2008 23:15:57 +0000 (23:15 +0000)
ext/rbbooh.cc

index 10ff24a..f2dfca0 100644 (file)
@@ -185,6 +185,9 @@ static VALUE load_not_freezing_ui(VALUE self, VALUE path, VALUE interruptable, V
         GdkPixbufLoader* loader = GDK_PIXBUF_LOADER(RVAL2GOBJ(self));
         GError* error = NULL;
         FILE* f = fopen(RVAL2CSTR(path), "r");
+        if (!f) {
+                rb_raise(rb_eRuntimeError, "Unable to open file %s for reading", RVAL2CSTR(path));
+        }
         counter++;
         while ((amount = fread(buf, 1, 65536, f)) > 0) {
                 if (!gdk_pixbuf_loader_write(loader, (const guchar*) buf, amount, &error)) {