]> granicus.if.org Git - sysstat/commitdiff
SVG: Init newly allocated strings
authorSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 22 Feb 2016 17:26:34 +0000 (18:26 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 22 Feb 2016 17:26:34 +0000 (18:26 +0100)
Graph definition is made of successive SVG "path" commands concatenated
together. Make sure that the strings allocated to receive these definitions
are initialized before being used.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
svg_stats.c

index 5b05c8f38ee1c70357f11e8aaae1936ba81f94f5..9b63d3cdccff18ecf71a24549d2dc38cec7b8ab6 100644 (file)
@@ -223,8 +223,9 @@ char **allocate_graph_lines(int n, int **outsize, double **spmin, double **spmax
                        exit(4);
                }
                *(out + i) = out_p;
+               *out_p = '\0';                  /* Reset string so that it can be safely strncat()'d later */
                *(*outsize + i) = CHUNKSIZE;    /* Each array of chars has a default size of CHUNKSIZE */
-               *(*spmin + i) = DBL_MAX;
+               *(*spmin + i) = DBL_MAX;        /* Init min and max values */
                *(*spmax + i) = -DBL_MAX;
        }