mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-27 17:18:33 +00:00
Border cases of scale < 1 would lead to negative lengths, crashing conky
e.g. in the beginning the scale is always 0, leading to NaN and a crash fixes the "show_graph_scale" not working bug, not yet reported (even though I actually noticed that before, didn't seem to bother me) also cpugauge works again because fo this BUILD_MATH MATH problem
This commit is contained in:
parent
a85ffd5d0d
commit
e7cdccd964
@ -1690,9 +1690,8 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
char *tmp_str;
|
char *tmp_str;
|
||||||
cur_x += font_ascent() / 2;
|
cur_x += font_ascent() / 2;
|
||||||
cur_y += font_h / 2;
|
cur_y += font_h / 2;
|
||||||
tmp_str = (char *)
|
const int tmp_str_len = 64;
|
||||||
calloc(log10(floor(current->scale)) + 4,
|
tmp_str = (char *) calloc(tmp_str_len, sizeof(char));
|
||||||
sizeof(char));
|
|
||||||
sprintf(tmp_str, "%.1f", current->scale);
|
sprintf(tmp_str, "%.1f", current->scale);
|
||||||
draw_string(tmp_str);
|
draw_string(tmp_str);
|
||||||
free(tmp_str);
|
free(tmp_str);
|
||||||
|
@ -289,8 +289,6 @@ char *scan_graph(struct text_object *obj, const char *args, double defscale)
|
|||||||
buf[_size] = 0;
|
buf[_size] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef g
|
|
||||||
|
|
||||||
return strndup(buf, text_buffer_size.get(*state));
|
return strndup(buf, text_buffer_size.get(*state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,6 +415,9 @@ void new_font(struct text_object *obj, char *p, int p_max_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds value f to graph possibly truncating and scaling the graph
|
||||||
|
**/
|
||||||
static void graph_append(struct special_t *graph, double f, char showaslog)
|
static void graph_append(struct special_t *graph, double f, char showaslog)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -537,7 +538,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
|||||||
s->scale = log10(s->scale + 1);
|
s->scale = log10(s->scale + 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
graph_append(s, val, g->flags & SF_SHOWLOG);
|
graph_append(s, val, g->flags);
|
||||||
|
|
||||||
if (not out_to_x.get(*state))
|
if (not out_to_x.get(*state))
|
||||||
new_graph_in_shell(s, buf, buf_max_size);
|
new_graph_in_shell(s, buf, buf_max_size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user