1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 10:35:10 +00:00

Clean up a few valgrind errors, add realloc-failure handling for graphs. (#367)

I think this fixes #360
This commit is contained in:
Darin McBride 2017-02-11 14:39:18 -07:00 committed by Brenden Matthews
parent e84ca1f966
commit a58a6d4e08
3 changed files with 10 additions and 5 deletions

View File

@ -521,11 +521,15 @@ 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;

View File

@ -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;
}

View File

@ -492,6 +492,7 @@ static void update_workarea(void)
workarea[1] = ps->y_org;
workarea[2] = workarea[0] + ps->width;
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]);