serial: fix memory leak in case of error out.
authorZhang Zhaolong <zhangzl2013@126.com>
Sat, 26 Apr 2014 04:24:56 +0000 (12:24 +0800)
committerZhang Zhaolong <zhangzl2013@126.com>
Sat, 26 Apr 2014 04:24:56 +0000 (12:24 +0800)
channels/serial/client/serial_tty.c

index 8e051e9..b71bd57 100644 (file)
@@ -426,8 +426,10 @@ BOOL serial_tty_read(SERIAL_TTY* tty, BYTE* buffer, UINT32* Length)
 
                ptermios = (struct termios*) calloc(1, sizeof(struct termios));
 
-               if (tcgetattr(tty->fd, ptermios) < 0)
+               if (tcgetattr(tty->fd, ptermios) < 0) {
+                       free(ptermios);
                        return FALSE;
+               }
 
                /**
                 * If a timeout is set, do a blocking read, which times out after some time.