Index: trunk/psphot/src/psphotOutput.c
===================================================================
--- trunk/psphot/src/psphotOutput.c	(revision 11726)
+++ trunk/psphot/src/psphotOutput.c	(revision 12546)
@@ -100,5 +100,5 @@
 
     // count the number of sources which will be written
-    for (int i = 0; i < sources->n; i++) {
+    for (int i = 0; (sources != NULL) && (i < sources->n); i++) {
         pmSource *source = (pmSource *) sources->data[i];
         pmModel *model = pmSourceSelectModel (source);
