projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
output-item: Fix memory leak in output_item_dump().
[pspp]
/
src
/
ui
/
gui
/
value-variant.c
diff --git
a/src/ui/gui/value-variant.c
b/src/ui/gui/value-variant.c
index f332ccff11045ede52f5d274cb3ac0ff3c2df9cf..7c85786f6c1745a2b7d0cb281c3022612109b055 100644
(file)
--- a/
src/ui/gui/value-variant.c
+++ b/
src/ui/gui/value-variant.c
@@
-1,5
+1,5
@@
/* PSPPIRE - a graphical user interface for PSPP.
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2016 Free Software Foundation
+ Copyright (C) 2016
, 2020
Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-17,11
+17,9
@@
#include <config.h>
#include <gtk/gtk.h>
#include <config.h>
#include <gtk/gtk.h>
-#include <string.h>
#include "value-variant.h"
#include "data/value.h"
#include "value-variant.h"
#include "data/value.h"
-
enum
{
IDX_WIDTH,
enum
{
IDX_WIDTH,
@@
-42,11
+40,9
@@
value_variant_new (const union value *in, int width)
vv[IDX_DATA] = g_variant_new_double (in->f);
else
{
vv[IDX_DATA] = g_variant_new_double (in->f);
else
{
- gchar *q = xmalloc (width + 1);
- memcpy (q, in->s, width);
- q[width] = '\0';
- vv[IDX_DATA] = g_variant_new_from_data (G_VARIANT_TYPE_BYTESTRING, q,
- width + 1, FALSE, NULL, NULL);
+ vv[IDX_DATA] = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
+ in->s, width,
+ sizeof (gchar));
}
return g_variant_new_tuple (vv, 2);
}
return g_variant_new_tuple (vv, 2);
@@
-79,9
+75,13
@@
value_variant_get (union value *val, GVariant *v)
val->f = g_variant_get_double (vdata);
else
{
val->f = g_variant_get_double (vdata);
else
{
- const gchar *data = g_variant_get_bytestring (vdata);
- size_t len = strlen (data);
- val->s = xmemdup (data, MIN (width, len));
+ gsize w;
+ const gchar *data =
+ g_variant_get_fixed_array (vdata, &w, sizeof (gchar));
+
+ if (w != width)
+ g_critical ("Value variant's width does not match its array size");
+ val->s = xmemdup (data, w);
}
g_variant_unref (vdata);
}
g_variant_unref (vdata);