GNOME Bugzilla – Bug 640975
Check that error exists before trying to set it
Last modified: 2011-09-18 00:28:47 UTC
Created attachment 179658 [details] [review]
See the patch.
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
- int errsv = errno;
- g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED,
- _("Error during conversion: %s"),
- g_strerror (errsv));
+ if (error)
+ int errsv = errno;
+ g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED,
+ _("Error during conversion: %s"),
+ g_strerror (errsv));
What exactly was the bug here? g_set_error already checks whether error is NULL, so as far as I can see, this change is unnecessary?
well, this was added to keep concordance with the other cases, but you are right, didn't know it was already checked. I guess the right solution here should be to remove the if (error) check in all places in this function.
Created attachment 179720 [details] [review]
See that it was already doing this check everywhere.
Created attachment 179773 [details] [review]
The following fix has been pushed:
7b9571e Remove redundant checks
Created attachment 196857 [details] [review]
Remove redundant checks
g_set_error() handles error == NULL, so no need to check.
Patch by Ignacio Casal Quinteiro.