diff options
author | Philip Withnall <withnall@endlessm.com> | 2018-08-16 15:36:32 +0100 |
---|---|---|
committer | Philip Withnall <withnall@endlessm.com> | 2018-08-16 15:36:32 +0100 |
commit | a44329c2442ff45d31fe7a0ca45005f145df3187 (patch) | |
tree | 8c8f6479536b68fbd69502cffcf9d17a96cd9551 /gvdb-reader.c | |
parent | 7bed7ea77dfd2634d3fceaafaacd9764bf76e709 (diff) | |
download | dconf-a44329c2442ff45d31fe7a0ca45005f145df3187.tar.gz |
Fix type of length returned by gvdb_table_get_names()
It should not be unsigned. The type in the on-disk format is gint32, so
we need to return something at least as wide as that. However, we
should not expose the implementation detail that the on-disk format is
specifically gint32. Use a gsize, since that’s the normal type for array
lengths — but check that we’re not on a platform where (somehow) gsize
is smaller than gint32.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Diffstat (limited to 'gvdb-reader.c')
-rw-r--r-- | gvdb-reader.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gvdb-reader.c b/gvdb-reader.c index c2ee84d..ae349a6 100644 --- a/gvdb-reader.c +++ b/gvdb-reader.c @@ -348,7 +348,7 @@ gvdb_table_list_from_item (GvdbTable *table, **/ gchar ** gvdb_table_get_names (GvdbTable *table, - gint *length) + gsize *length) { gchar **names; gint n_names; @@ -474,7 +474,10 @@ gvdb_table_get_names (GvdbTable *table, } if (length) - *length = n_names; + { + G_STATIC_ASSERT (sizeof (*length) >= sizeof (n_names)); + *length = n_names; + } return names; } |