[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-user: Segfault in PS hid -> patch



Hi,

I got a segfault when I tried to export a pcb to postscript with the multifile option enabled and a wrong path supplied in the psfile field. The attached patch adds a few sanity checks to fix that and spew an error on stderr.
The patch is applied against CVS from January 10.

Kind regards,

Hans

-- 

$ cat .sig /dev/null
--- pcb/src/hid/ps/ps.c	2007-01-10 01:41:24.000000000 +0100
+++ pcb-filenotfound/src/hid/ps/ps.c	2007-01-11 21:15:38.000000000 +0100
@@ -372,7 +372,8 @@
   lastgroup = -1;
   hid_expose_callback (&ps_hid, &region, 0);
 
-  fprintf (f, "showpage\n");
+  if (f)
+    fprintf (f, "showpage\n");
 
   memcpy (LayerStack, saved_layer_stack, sizeof (LayerStack));
 }
@@ -415,7 +416,8 @@
   hid_restore_layer_ons (save_ons);
 
   multi_file = 0;
-  fclose (f);
+  if (f)
+   fclose (f);
 }
 
 extern void hid_parse_command_line (int *argc, char ***argv);
@@ -506,6 +508,12 @@
 	  if (f)
 	    fclose (f);
 	  f = psopen (filename, layer_type_to_file_name (idx));
+	  if (!f)
+	  {
+	    perror(filename);
+	    return 0;
+	  }
+		  
 	  ps_start_file (f);
 	}
       fprintf (f, "%%%%Page: %d\n", pagecount);

_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user