After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 754026 - gfileutils: add some sanity checks
gfileutils: add some sanity checks
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.45.x
Other Linux
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-08-24 14:27 UTC by Aurélien Zanelli
Modified: 2017-10-05 12:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gfileutils: add some sanity checks (1.38 KB, patch)
2015-08-24 14:28 UTC, Aurélien Zanelli
none Details | Review
gfileutils: add some sanity checks (1.70 KB, patch)
2015-08-31 08:40 UTC, Aurélien Zanelli
committed Details | Review

Description Aurélien Zanelli 2015-08-24 14:27:38 UTC
While developing an app using glib, I ended up with some spurious segfault due to the fact I was passing uninitialized and non-null GError to g_dir_make_tmp() function. To avoid programming errors with this function, I propose to add a sanity check.
Comment 1 Aurélien Zanelli 2015-08-24 14:28:55 UTC
Created attachment 309923 [details] [review]
gfileutils: add some sanity checks

To avoid handling non-null GError or NULL filename in some fileutils functions.
Comment 2 Matthias Clasen 2015-08-27 02:12:10 UTC
not really in favour of littering the code with these
Comment 3 Aurélien Zanelli 2015-08-31 08:40:30 UTC
Created attachment 310332 [details] [review]
gfileutils: add some sanity checks

Update to fix compiler warning about mixing code an declaration.
Comment 4 Aurélien Zanelli 2015-08-31 08:41:04 UTC
(In reply to Matthias Clasen from comment #2)
> not really in favour of littering the code with these

Some other functions in this file, and more generally in GLib, check bad input parameters (GError, strings...). So I think an user can expect GLib functions to tell him when he is doing wrong. It's also make usage of GLib more coherent in my opinion.
Comment 5 Philip Withnall 2017-10-05 12:43:51 UTC
I”ve updated this to apply cleanly to master, and to s/FALSE/-1/ one of the precondition failure return values (to match the function documentation).

If people are worried about the performance impact of this, they should be compiling GLib with G_DISABLE_CHECKS to disable all precondition checks. The presence of precondition checks helps developers diagnose failures, and provides hints to static analysis tools.

Attachment 310332 [details] pushed as 21d2c64 - gfileutils: add some sanity checks