Remove segv in xpm2ps, fixes #611
authorCarsten Kutzner <ckutzne@gwdg.de>
Fri, 26 Aug 2011 14:05:41 +0000 (16:05 +0200)
committerCarsten Kutzner <ckutzne@gwdg.de>
Fri, 26 Aug 2011 14:05:41 +0000 (16:05 +0200)
Issue a fatal error if matrix elements are to be
added/subtracted/multiplied/divided (with xpm2ps -compine) but no
proper matrix data could be extracted from one of the xpm files.

src/tools/gmx_xpm2ps.c

index fb057f4a3335f83fd191010933074f3d9ce36b27..317a736c5edd9b5e5e33ee029784d901bad2b53e 100644 (file)
@@ -941,6 +941,12 @@ void write_combined_matrix(int ecombine, const char *fn,
     printf("Combining two %dx%d matrices\n",mat1[k].nx,mat1[k].ny);
     rmat1 = matrix2real(&mat1[k], NULL);
     rmat2 = matrix2real(&mat2[k], NULL);
+    if (NULL == rmat1 || NULL == rmat2)
+    {
+        gmx_fatal(FARGS, "Could not extract real data from %s xpm matrices. Note that, e.g.,\n"
+                         "g_rms and g_mdmat provide such data, but not do_dssp.\n",
+                         (NULL==rmat1 && NULL==rmat2) ? "both" : "one of the" );
+    }
     rlo=1e38;
     rhi=-1e38;
     for(j=0; j<mat1[k].ny; j++)