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 10ff24ae75f3db5a05c490aec8b3ba85cdd07860..f2dfca04d9a8fb2ca1f751f924d99a159cb7c49c 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)) {