g_error_free() warning on null pointer
- Date: Sat, 15 Aug 2015 16:28:30 -0400
- From: Michael McConville <mmcconv1@xxxxxxxxxxxxxxxxxxx>
- Subject: g_error_free() warning on null pointer
If you call g_error_free() on a null pointer, you'll see something like
> (process:345): GLib-CRITICAL **: g_error_free: assertion 'error != NULL' failed
However, POSIX specifies:
> If ptr is a null pointer, no action shall occur.
>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:
gtk-devel-list mailing list