Index: image_gallery.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_gallery/image_gallery.module,v
retrieving revision 1.19
diff -u -p -u -r1.19 image_gallery.module
--- image_gallery.module	7 Sep 2007 19:22:19 -0000	1.19
+++ image_gallery.module	7 Sep 2007 19:23:57 -0000
@@ -147,8 +147,9 @@ function image_gallery_page($type = NULL
     // The values of $descendant_tids should be safe for raw inclusion in the
     // SQL since they're all loaded from integer fields in the database.
     $sql = 'SELECT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. implode(',', $descendant_tids) .') AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC';
-    $last = db_fetch_object(db_query_range(db_rewrite_sql($sql), 0, 1));
-    $galleries[$i]->latest = node_load(array('nid' => $last->nid));
+    if ($nid = db_result(db_query_range(db_rewrite_sql($sql), 0, 1))) {
+      $galleries[$i]->latest = node_load(array('nid' => $nid));
+    }
   }
 
   $images = array();

