- add gkrellm_store_chartdatav() that takes a va_list instead of varargs. This fixes a potential crash caused by plugins using gkrellm_store_chartdata on win32 (same problem as with gkrellm_debug(), the win32 plugin-interface needs a va_list version of every vararg function in gkrellm).

This commit is contained in:
Stefan Gehn 2008-12-27 13:21:11 +00:00
parent 0d35922472
commit abcce9a6b1
5 changed files with 33 additions and 17 deletions

View File

@ -809,6 +809,17 @@ void
gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
{
va_list args;
if (!cp)
return;
va_start(args, total);
gkrellm_store_chartdatav(cp, total, args);
va_end(args);
}
void
gkrellm_store_chartdatav(GkrellmChart *cp, gulong total, va_list args)
{
GList *list;
GkrellmChartdata *cd;
gulong range, total_diff;
@ -818,10 +829,10 @@ gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
if (!cp)
return;
va_start(args, total);
for (list = cp->cd_list; list; list = list->next)
{
cd = (GkrellmChartdata *) list->data;
//FIXME: missing check for number of passed varargs passed in "args"
cd->current = va_arg(args, gulong);
if (!cd->monotonic)
{
@ -833,7 +844,6 @@ gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
if (cd->current < cd->previous || !cp->primed)
cd->previous = cd->current;
}
va_end(args);
if (total < cp->previous_total || !cp->primed)
cp->previous_total = total; /* Wrap around, this store won't scale */
total_diff = total - cp->previous_total;

View File

@ -93,6 +93,7 @@ GkrellmChartdata *gkrellm_add_chartdata(GkrellmChart *, GdkPixmap **,
GkrellmChartdata *gkrellm_add_default_chartdata(GkrellmChart *, gchar *);
void gkrellm_alloc_chartdata(GkrellmChart *);
void gkrellm_store_chartdata(GkrellmChart *, gulong, ...);
void gkrellm_store_chartdatav(GkrellmChart *cp, gulong total, va_list args);
void gkrellm_draw_chartdata(GkrellmChart *);
void gkrellm_monotonic_chartdata(GkrellmChartdata *, gboolean);
gboolean gkrellm_get_chartdata_hide(GkrellmChartdata *);

View File

@ -195,12 +195,16 @@ void gkrellm_alloc_chartdata(GkrellmChart *a)
{
(*(callbacks->gkrellm_alloc_chartdata))(a);
}
void gkrellm_store_chartdata(GkrellmChart *a, gulong b, ...)
void gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
{
va_list ap;
va_start(ap, b);
callbacks->gkrellm_store_chartdata(a, b, ap);
va_end(ap);
va_list args;
va_start(args, total);
callbacks->gkrellm_store_chartdatav(cp, total, args);
va_end(args);
}
void gkrellm_store_chartdatav(GkrellmChart *cp, gulong total, va_list args)
{
callbacks->gkrellm_store_chartdatav(cp, total, args);
}
void gkrellm_draw_chartdata(GkrellmChart *a)
{

View File

@ -82,7 +82,7 @@ void win32_init_callbacks(void)
gkrellm_callbacks.gkrellm_add_chartdata = gkrellm_add_chartdata;
gkrellm_callbacks.gkrellm_add_default_chartdata = gkrellm_add_default_chartdata;
gkrellm_callbacks.gkrellm_alloc_chartdata = gkrellm_alloc_chartdata;
gkrellm_callbacks.gkrellm_store_chartdata = gkrellm_store_chartdata;
gkrellm_callbacks.gkrellm_store_chartdatav = gkrellm_store_chartdatav;
gkrellm_callbacks.gkrellm_draw_chartdata = gkrellm_draw_chartdata;
gkrellm_callbacks.gkrellm_monotonic_chartdata = gkrellm_monotonic_chartdata;
gkrellm_callbacks.gkrellm_get_chartdata_hide = gkrellm_get_chartdata_hide;

View File

@ -82,7 +82,8 @@ typedef struct
GdkPixmap *, gchar *);
GkrellmChartdata *(*gkrellm_add_default_chartdata)(GkrellmChart *, gchar *);
void (*gkrellm_alloc_chartdata)(GkrellmChart *);
void (*gkrellm_store_chartdata)(GkrellmChart *, gulong, ...);
// gkrellm_store_chartdata is not called from libgkrellm, only gkrellm_store_chartdatav
void (*gkrellm_store_chartdatav)(GkrellmChart *, gulong, ...);
void (*gkrellm_draw_chartdata)(GkrellmChart *);
void (*gkrellm_monotonic_chartdata)(GkrellmChartdata *, gboolean);
gboolean (*gkrellm_get_chartdata_hide)(GkrellmChartdata *);