g_error_free() warning on null pointer
- From: Michael McConville <mmcconv1 sccs swarthmore edu>
- To: gtk-devel-list gnome org
- Subject: g_error_free() warning on null pointer
- Date: Sat, 15 Aug 2015 16:28:30 -0400
If you call g_error_free() on a null pointer, you'll see something like
this:
(process:345): GLib-CRITICAL **: g_error_free: assertion 'error != NULL' failed
However, POSIX specifies:
If ptr is a null pointer, no action shall occur.
http://pubs.opengroup.org/onlinepubs/009695399/functions/free.html
From what I've seen, all major Unices comply with this and mention it in
their man page. While printing that warning may not be a program action,
it's definitely disconcerting and dilutes debug logs. It seems to me
that POSIX intends free() to be used in situations in which the pointer
may be null. This is common practice.
Additionally, g_clear_error() doesn't print a warning when passed NULL.
Fixing this would just involve removing this line:
https://github.com/GNOME/glib/blob/master/glib/gerror.c#L467
Thoughts?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]