diff --git a/src/specials.cc b/src/specials.cc index 73bd2a22..d8ac8b0d 100644 --- a/src/specials.cc +++ b/src/specials.cc @@ -521,12 +521,16 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val) /* initialize */ std::fill_n(graph, s->graph_width, 0.0); s->scale = 100; - } else { + } else if (graph) { if (s->graph_width > s->graph_allocated) { /* initialize the new region */ std::fill(graph + s->graph_allocated, graph + s->graph_width, 0.0); } - } + } else { + DBGP("reallocing FAILED"); + graph = s->graph; + s->graph_width = s->graph_allocated; + } s->graph = graph; s->graph_allocated = s->graph_width; } diff --git a/src/template.cc b/src/template.cc index 17d63b12..98b9f682 100644 --- a/src/template.cc +++ b/src/template.cc @@ -99,8 +99,8 @@ static char *backslash_escape(const char *src, char **templates, unsigned int te } p++; } - src_dup[dup_idx] = '\0'; - src_dup = (char*) realloc(src_dup, (strlen(src_dup) + 1) * sizeof(char)); + src_dup[dup_idx++] = '\0'; + src_dup = (char*) realloc(src_dup, dup_idx * sizeof(char)); return src_dup; } diff --git a/src/x11.cc b/src/x11.cc index 682c8d72..216fe22e 100644 --- a/src/x11.cc +++ b/src/x11.cc @@ -491,7 +491,8 @@ static void update_workarea(void) workarea[0] = ps->x_org; workarea[1] = ps->y_org; workarea[2] = workarea[0] + ps->width; - workarea[3] = workarea[1] + ps->height; + workarea[3] = workarea[1] + ps->height; + XFree(si); DBGP("Fixed xinerama area to: %d %d %d %d", workarea[0], workarea[1], workarea[2], workarea[3]);