GNOME Bugzilla – Bug 731305
gfileutils.c error handling broken
Last modified: 2017-10-05 13:01:54 UTC
gfileutils.c makes heavy use of utility function set_file_error. While that function work, none of the calls to it are correct. Here's a sample call: set_file_error (error, filename, _("Failed to open file '%s': %s")); The problem is that gettext (aka "_") can change errno at will. Here's what that call should have looked like: int save_errno = errno; const char *fmt = _("Failed to open file '%s': %s"); errno = save_errno; set_file_error (error, filename, fmt); That looks crazy, so I would suggest to use N_(...) instead of _(...) and have set_file_error call _. For that to work right, format_error_message would need to have the error number as an argument.
This was fixed in commit 6680ff1ee93127b247f8ca32958620ec7db6af48 (bug #725514). *** This bug has been marked as a duplicate of bug 725514 ***