From d86a422c59cdcc3d3ccf40019b12e8d53df2a673 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Tue, 26 Jul 2022 12:05:28 +0200 Subject: [PATCH] do not segfault if reading ascii raw files. print error message and tell user to generate binary rawfile. --- src/save.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/save.c b/src/save.c index a2005703..127c6d59 100644 --- a/src/save.c +++ b/src/save.c @@ -301,6 +301,14 @@ static int read_dataset(FILE *fd) while((ptr = fgets(line, sizeof(line), fd)) ) { /* after this line comes the binary blob made of nvars * npoints * sizeof(double) bytes */ + if(!strcmp(line, "Values:\n")) { /* this is an ASCII raw file. We don't handle this (yet) */ + free_rawfile(0); + dbg(0, "read_dataset(): ASCII raw files can not be read. " + "Use binary format in ngspice (set filetype=binary)\n"); + tcleval("alert_ {read_dataset(): ASCII raw files can not be read. " + "Use binary format in ngspice (set filetype=binary)}"); + return 0; + } if(!strcmp(line, "Binary:\n")) { int npoints = xctx->graph_npoints[xctx->graph_datasets]; if(xctx->graph_sim_type) {