free seems to touch errno on windows...?

Signed-off-by: Stefan Tauner <[email protected]>
---
 serial.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/serial.c b/serial.c
index 7e47dcc..11a749c 100644
--- a/serial.c
+++ b/serial.c
@@ -109,6 +109,7 @@ fdtype sp_openserport(char *dev, unsigned int baud)
 #ifdef _WIN32
        HANDLE fd;
        char *dev2 = dev;
+       int err;
        if ((strlen(dev) > 3) && (tolower((unsigned char)dev[0]) == 'c') &&
            (tolower((unsigned char)dev[1]) == 'o') &&
            (tolower((unsigned char)dev[2]) == 'm')) {
@@ -122,10 +123,11 @@ fdtype sp_openserport(char *dev, unsigned int baud)
        }
        fd = CreateFile(dev2, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                        OPEN_EXISTING, 0, NULL);
+       err = errno; // free may change errno
        if (dev2 != dev)
                free(dev2);
        if (fd == INVALID_HANDLE_VALUE) {
-               msg_perr("Error: cannot open serial port: %s\n", 
strerror(errno));
+               msg_perr("Error: cannot open serial port: %s\n", strerror(err));
                return SER_INV_FD;
        }
        DCB dcb;
-- 
Kind regards, Stefan Tauner


_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to