From f85d46a0cbc436d23ccf364d1140f728f951d6f6 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 22 Jun 2023 08:16:19 +0200 Subject: [PATCH] save_schematic(): avoid copying schname to xctx->sch[xctx->currsch] if dest == src --- src/save.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/save.c b/src/save.c index a88066b0..deabdecd 100644 --- a/src/save.c +++ b/src/save.c @@ -2330,8 +2330,11 @@ int save_schematic(const char *schname) /* 20171020 added return value */ xRect *rect; int rects; - if( strcmp(schname,"") ) my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], schname); - else return 0; + if( strcmp(schname,"")) { + if(!xctx->sch[xctx->currsch] || strcmp(schname, xctx->sch[xctx->currsch])) { + my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], schname); + } + } else return 0; dbg(1, "save_schematic(): currsch=%d name=%s\n",xctx->currsch, schname); dbg(1, "save_schematic(): sch[currsch]=%s\n", xctx->sch[xctx->currsch]); /* dbg(1, "save_schematic(): abs_sym_path=%s\n", abs_sym_path(xctx->sch[xctx->currsch], "")); */