From 7eb03612dc8d6016c696650284dc618c441b5675 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Thu, 20 Jul 2017 14:03:40 +0200
Subject: [PATCH] oixy segfaulted when nz=0

---
 pub/CHANGELOG   |  1 +
 pub/lib/opr.cpp | 12 ++++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/pub/CHANGELOG b/pub/CHANGELOG
index 2ac31a42..d6cf0685 100644
--- a/pub/CHANGELOG
+++ b/pub/CHANGELOG
@@ -1,6 +1,7 @@
 - Use plot.Y.force in 2d plotting
 - Use wx, wy, wh in setting ticks and tacks for easier editing of PS file
 - Correct ticks and tacks for small log range
+- correct handling of Z in oixy
 
 Release 2.4.0b of 21apr17:
 
diff --git a/pub/lib/opr.cpp b/pub/lib/opr.cpp
index 97cc46ce..0b325e7c 100644
--- a/pub/lib/opr.cpp
+++ b/pub/lib/opr.cpp
@@ -352,6 +352,8 @@ void NOperate::IntXY(string mode)
     }
 
     while (const COld* fin = fiter.nextD()) {
+        int nz = fin->ZCo.size();
+
         POld fout(fin->new_POld());
         string lin = S("oi") + mode + " " + S(icolx) + " " + S(icoly);
         if (with_d)
@@ -360,12 +362,13 @@ void NOperate::IntXY(string mode)
 
         fout->xco = CCoord("x", "");
         fout->yco = CCoord("y", "");
-        fout->ZCo.pop_back();
-        int nz = fin->ZCo.size();
+        if (nz)
+            fout->ZCo.pop_back();
 
         PSpec sout(new CSpec);
         sout->z = fin->V[0]->z;
-        sout->z.pop_back();
+        if (nz)
+            sout->z.pop_back();
 
         for (int j = 0; j < fin->nJ(); j++) {
             int n = fin->nPts(j);
@@ -382,7 +385,8 @@ void NOperate::IntXY(string mode)
                     fout->V.push_back(move(sout));
                     sout = PSpec(new CSpec);
                     sout->z = fin->V[j+1]->z;
-                    sout->z.pop_back();
+                    if (nz)
+                        sout->z.pop_back();
                 }
             }
         }
-- 
GitLab