diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2017-10-03 14:29:00 +0800 |
---|---|---|
committer | Mathieu Duponchelle <mathieu@centricular.com> | 2018-04-20 18:26:08 +0200 |
commit | c8525c461fa7f5f68ccfd9c332e6a6bbdd9090d3 (patch) | |
tree | 1ffaf5e88a04110367f4953183328f73612f5d8b /girepository | |
parent | b010c1241227201581841122912f307d2311455a (diff) | |
download | gobject-introspection-c8525c461fa7f5f68ccfd9c332e6a6bbdd9090d3.tar.gz |
girepository: Properly acquire and check pointer values
On Windows (Visual Studio at least), unsigned longs are always 4 bytes,
on both 32-bit and x64 Windows, so we cannot use unsigned longs to deal
with pointers on 64-bit builds, as pointers are 8 bytes on 64-bit
Windows, which may well render the pointer (which we acquired from
libffi) invalid.
This will fix crashes in PyGObject which are manifested when launching
the cairo-demo example sript (intermittent) and when clicking on
"Interactive Dialog" button in the Dialog demo in the PyGObject GTK+
Code demos before entering anything in Entry 1 and Entry 2, when running
on x64 Visual Studio builds of the GTK+/PyGObject stack.
Also use size_t instead of unsigned long in gthash.c when we check that
memory & 0x3 is 0, to silence compiler warnings from enabling /Wp64,
which is used to detect portability problems on Visual Studio when
doing x86->x64 code builds.
https://bugzilla.gnome.org/show_bug.cgi?id=702788
Diffstat (limited to 'girepository')
-rw-r--r-- | girepository/gicallableinfo.c | 4 | ||||
-rw-r--r-- | girepository/gthash.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index bfbcc255..5f923d1a 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -535,7 +535,7 @@ gi_type_info_extract_ffi_return_value (GITypeInfo *return_info, arg->v_int32 = (gint32) ffi_value->v_long; break; default: - arg->v_pointer = (gpointer) ffi_value->v_ulong; + arg->v_pointer = (gpointer) ffi_value->v_pointer; break; } @@ -543,7 +543,7 @@ gi_type_info_extract_ffi_return_value (GITypeInfo *return_info, } break; default: - arg->v_pointer = (gpointer) ffi_value->v_ulong; + arg->v_pointer = (gpointer) ffi_value->v_pointer; break; } } diff --git a/girepository/gthash.c b/girepository/gthash.c index 7440913a..2fda9035 100644 --- a/girepository/gthash.c +++ b/girepository/gthash.c @@ -158,7 +158,7 @@ _gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, guint8* mem, guint g_return_if_fail (builder->buildable); g_assert (len >= builder->packed_size); - g_assert ((((unsigned long)mem) & 0x3) == 0); + g_assert ((((size_t)mem) & 0x3) == 0); memset (mem, 0, len); @@ -202,7 +202,7 @@ _gi_typelib_hash_search (guint8* memory, const char *str, guint n_entries) guint32 dirmap_offset; guint32 offset; - g_assert ((((unsigned long)memory) & 0x3) == 0); + g_assert ((((size_t)memory) & 0x3) == 0); mph = ((guint32*)memory)+1; offset = cmph_search_packed (mph, str, strlen (str)); |