Re: Null check in g_hash_table_lookup()
- From: "Jasper St. Pierre" <jstpierre mecheye net>
- To: Michael McConville <mmcconv1 sccs swarthmore edu>
- Cc: gtk-devel-list <gtk-devel-list gnome org>
- Subject: Re: Null check in g_hash_table_lookup()
- Date: Sat, 15 Aug 2015 14:14:22 -0700
It will fix it in that it will warn and then return NULL (and only if
you build glib with the flag that turns those return_val_if_fail's on,
which it does by default), but it's considered improper behavior to
call g_hash_table_lookup with a NULL key.
On Sat, Aug 15, 2015 at 1:27 PM, Michael McConville
<mmcconv1 sccs swarthmore edu> wrote:
Currently, if you pass a null key pointer to g_hash_table_lookup(), it
will sometimes segfault in g_str_hash(). This often happened in the
Pidgin development tip until we added this check:
https://hg.pidgin.im/pidgin/main/rev/7e57fa4513f4
I was running GLib 2.44.1 on OpenBSD 5.8 (-current).
It seems like adding:
g_return_val_if_fail (key != NULL, NULL);
Here:
https://github.com/GNOME/glib/blob/master/glib/ghash.c#L1145
Should fix it. However, it seems saliently missing, so maybe I'm
misunderstanding and NULL can be a valid key pointer.
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list
--
Jasper
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]