diff --git a/src/common.c b/src/common.c index c4099d0c..3c65f52b 100644 --- a/src/common.c +++ b/src/common.c @@ -464,8 +464,8 @@ void scan_loadgraph_arg(struct text_object *obj, const char *arg) free(buf); } -void print_loadgraph(struct text_object *obj, char *p) +void print_loadgraph(struct text_object *obj, char *p, int p_max_size) { - new_graph(obj, p, info.loadavg[0]); + new_graph(obj, p, p_max_size, info.loadavg[0]); } #endif /* X11 */ diff --git a/src/common.h b/src/common.h index 4dadab21..2c1ddd17 100644 --- a/src/common.h +++ b/src/common.h @@ -72,7 +72,7 @@ void scan_loadavg_arg(struct text_object *, const char *); void print_loadavg(struct text_object *, char *, int); #ifdef X11 void scan_loadgraph_arg(struct text_object *, const char *); -void print_loadgraph(struct text_object *, char *); +void print_loadgraph(struct text_object *, char *, int); #endif /* X11 */ #endif /* _COMMON_H */ diff --git a/src/conky.c b/src/conky.c index e7d28e12..5f04df17 100644 --- a/src/conky.c +++ b/src/conky.c @@ -902,10 +902,10 @@ void generate_text_internal(char *p, int p_max_size, } #ifdef X11 OBJ(cpugraph) { - new_graph(obj, p, round_to_int(cur->cpu_usage[obj->data.i] * 100)); + new_graph(obj, p, p_max_size, round_to_int(cur->cpu_usage[obj->data.i] * 100)); } OBJ(loadgraph) { - print_loadgraph(obj, p); + print_loadgraph(obj, p, p_max_size); } #endif /* X11 */ OBJ(color) { @@ -1373,7 +1373,7 @@ void generate_text_internal(char *p, int p_max_size, } #ifdef X11 OBJ(memgraph) { - new_graph(obj, p, cur->memmax ? (cur->mem * 100.0) / (cur->memmax) : 0.0); + new_graph(obj, p, p_max_size, cur->memmax ? (cur->mem * 100.0) / (cur->memmax) : 0.0); } #endif /* X11 */ /* mixer stuff */ @@ -2325,7 +2325,7 @@ void generate_text_internal(char *p, int p_max_size, OBJ(apcupsd_loadgraph) { double progress; progress = atof(cur->apcupsd.items[APCUPSD_LOAD]); - new_graph(obj, p, (int)progress); + new_graph(obj, p, p_max_size, (int)progress); } #endif /* X11 */ OBJ(apcupsd_loadgauge) { diff --git a/src/diskio.c b/src/diskio.c index 75fd2962..de49f1de 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -183,7 +183,7 @@ static void print_diskiograph_dir(struct text_object *obj, int dir, char *p, int else val = diskio->current_write; - new_graph(obj, p, val); + new_graph(obj, p, p_max_size, val); } void print_diskiograph(struct text_object *obj, char *p, int p_max_size) diff --git a/src/exec.c b/src/exec.c index 79cda00a..4057d099 100644 --- a/src/exec.c +++ b/src/exec.c @@ -387,7 +387,7 @@ void print_execgraph(struct text_object *obj, char *p, int p_max_size) barnum = get_barnum(p); if (barnum > 0) { - new_graph(obj, p, round_to_int(barnum)); + new_graph(obj, p, p_max_size, round_to_int(barnum)); } } @@ -409,7 +409,7 @@ void print_execigraph(struct text_object *obj, char *p, int p_max_size) } ed->last_update = current_update_time; } - new_graph(obj, p, (int) (ed->barnum)); + new_graph(obj, p, p_max_size, (int) (ed->barnum)); } #endif /* X11 */ diff --git a/src/llua.c b/src/llua.c index 750c8f37..bb9b2d32 100644 --- a/src/llua.c +++ b/src/llua.c @@ -563,7 +563,7 @@ void print_lua_graph(struct text_object *obj, char *p, int p_max_size) return; if (llua_getnumber(obj->data.s, &per)) { - new_graph(obj, p, per); + new_graph(obj, p, p_max_size, per); } } #endif /* X11 */ diff --git a/src/net_stat.c b/src/net_stat.c index 05d55d1b..79cb6c63 100644 --- a/src/net_stat.c +++ b/src/net_stat.c @@ -213,7 +213,7 @@ void print_downspeedgraph(struct text_object *obj, char *p, int p_max_size) if (!ns || !p_max_size) return; - new_graph(obj, p, ns->recv_speed / 1024.0); + new_graph(obj, p, p_max_size, ns->recv_speed / 1024.0); } void print_upspeedgraph(struct text_object *obj, char *p, int p_max_size) @@ -223,7 +223,7 @@ void print_upspeedgraph(struct text_object *obj, char *p, int p_max_size) if (!ns || !p_max_size) return; - new_graph(obj, p, ns->trans_speed / 1024.0); + new_graph(obj, p, p_max_size, ns->trans_speed / 1024.0); } #endif /* X11 */ diff --git a/src/specials.c b/src/specials.c index 859da86a..9a30b669 100644 --- a/src/specials.c +++ b/src/specials.c @@ -339,7 +339,7 @@ static void graph_append(struct special_t *graph, double f, char showaslog) } } -void new_graph(struct text_object *obj, char *buf, double val) +void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val) { struct special_t *s = 0; struct graph *g = obj->special_data; @@ -347,7 +347,7 @@ void new_graph(struct text_object *obj, char *buf, double val) if ((output_methods & TO_X) == 0) return; - if (!g) + if (!g || !buf_max_size) return; s = new_special(buf, GRAPH); diff --git a/src/specials.h b/src/specials.h index 101306f7..e250e3f9 100644 --- a/src/specials.h +++ b/src/specials.h @@ -104,7 +104,7 @@ void scan_stippled_hr(struct text_object *, const char*); /* printing specials */ void new_font(char *, char *); -void new_graph(struct text_object *, char *, double); +void new_graph(struct text_object *, char *, int, double); void new_hr(char *, int); void new_stippled_hr(struct text_object *, char *); #endif