chiark / gitweb /
Fix a misuse of errno.
authorSimon Tatham <anakin@pobox.com>
Tue, 6 Nov 2018 18:33:21 +0000 (18:33 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 6 Nov 2018 18:37:23 +0000 (18:37 +0000)
In menu_save_event, we checked ctx.error to see if an errno value had
been left in it by the savefile_write callback, but if so, then we
were passing the _current_ value of errno to strerror() in place of
the saved value in ctx.error.

This may well have been benign, but I spotted it in an eyeball review
just now and thought I'd better fix it before it bit anyone.

gtk.c

diff --git a/gtk.c b/gtk.c
index c3115b58162793838dd613c1aafa977e711cd714..20a6c0a06a2844a8f547ccd5f448e5a579b3571f 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -2287,7 +2287,7 @@ static void menu_save_event(GtkMenuItem *menuitem, gpointer data)
            if (ctx.error) {
                char boxmsg[512];
                sprintf(boxmsg, "Error writing save file: %.400s",
-                       strerror(errno));
+                       strerror(ctx.error));
                error_box(fe->window, boxmsg);
                goto free_and_return;
            }