From 7d7494815445880863f79dd73979a411b2cac373 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Wed, 20 May 2026 00:58:45 +0200 Subject: [PATCH] graph X and Y full zoom: handle the case raw file not loaded because malformed. --- src/draw.c | 28 ++++++++++++++++++++++++---- src/save.c | 4 ++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/draw.c b/src/draw.c index 828efb2a..c2c6b913 100644 --- a/src/draw.c +++ b/src/draw.c @@ -2607,7 +2607,11 @@ int graph_fullxzoom(int i, Graph_ctx *gr, int dataset) } my_strdup2(_ALLOC_ID_, &sim_type, get_tok_value(r->prop_ptr,"sim_type", 0)); if((i == xctx->graph_master) && custom_rawfile[0]) { - extra_rawfile(autoload, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type, -1.0, -1.0); + if(!extra_rawfile(autoload, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type, -1.0, -1.0)) { + if(custom_rawfile) my_free(_ALLOC_ID_, &custom_rawfile); + if(sim_type) my_free(_ALLOC_ID_, &sim_type); + return 0; + } } idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL); dbg(1, "graph_fullxzoom(): sweep idx=%d\n", idx); @@ -2625,7 +2629,11 @@ int graph_fullxzoom(int i, Graph_ctx *gr, int dataset) my_strdup2(_ALLOC_ID_, &sim_type, get_tok_value(xctx->rect[GRIDLAYER][xctx->graph_master].prop_ptr,"sim_type", 0)); if(custom_rawfile[0]) { - extra_rawfile(autoload, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type, -1.0, -1.0); + if(!extra_rawfile(autoload, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type, -1.0, -1.0)) { + if(custom_rawfile) my_free(_ALLOC_ID_, &custom_rawfile); + if(sim_type) my_free(_ALLOC_ID_, &sim_type); + return 0; + } } } @@ -2721,7 +2729,13 @@ int graph_fullyzoom(xRect *r, Graph_ctx *gr, int graph_dataset) char str_extra_idx[30]; if(sch_waves_loaded() != -1 && custom_rawfile[0]) { - extra_rawfile(autoload, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type, -1.0, -1.0); + if(!extra_rawfile(autoload, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type, -1.0, -1.0)) { + my_free(_ALLOC_ID_, &node); + my_free(_ALLOC_ID_, &sweep); + my_free(_ALLOC_ID_, &custom_rawfile); + my_free(_ALLOC_ID_, &sim_type); + return 0; + } } raw = xctx->raw; my_strdup2(_ALLOC_ID_, &nd, find_nth(ntok, "%", "\"", 0, 2)); @@ -2739,7 +2753,13 @@ int graph_fullyzoom(xRect *r, Graph_ctx *gr, int graph_dataset) sim_type[0] ? sim_type : xctx->raw->sim_type); dbg(1, "node_rawfile=|%s| node_sim_type=|%s|\n", node_rawfile, node_sim_type); if(node_rawfile && node_rawfile[0]) { - extra_rawfile(autoload, node_rawfile, node_sim_type, -1.0, -1.0); + if(!extra_rawfile(autoload, node_rawfile, node_sim_type, -1.0, -1.0)) { + my_free(_ALLOC_ID_, &node); + my_free(_ALLOC_ID_, &sweep); + my_free(_ALLOC_ID_, &custom_rawfile); + my_free(_ALLOC_ID_, &sim_type); + return 0; + } raw = xctx->raw; } my_free(_ALLOC_ID_, &node_rawfile); diff --git a/src/save.c b/src/save.c index 8c3b72f2..019e21d7 100644 --- a/src/save.c +++ b/src/save.c @@ -2324,6 +2324,10 @@ double get_raw_value(int dataset, int idx, int point) { int i, ofs; ofs = 0; + if(xctx->raw == NULL) { + dbg(0, "get_raw_value(): no spice raw file loaded\n"); + return 0.0; + } if(dataset >= xctx->raw->datasets) { dbg(0, "get_raw_value(): dataset(%d) >= datasets(%d)\n", dataset, xctx->raw->datasets); }