]> sigrok.org Git - libsigrok.git/commitdiff
serial.c: Use g_try_malloc().
authorUwe Hermann <redacted>
Sat, 16 Apr 2011 14:07:28 +0000 (16:07 +0200)
committerUwe Hermann <redacted>
Sat, 16 Apr 2011 16:08:18 +0000 (18:08 +0200)
hardware/common/serial.c

index 5205c188e6b785beeac473ff3e6db9dc0b38b0cc..b98d3c95e82f76d5bb573ef3bc1a58e98ab2b1f8 100644 (file)
@@ -163,7 +163,12 @@ void *serial_backup_params(int fd)
 #else
        struct termios *term;
 
-       term = malloc(sizeof(struct termios));
+       /* TODO: 'term' is never g_free()'d? */
+       if (!(term = g_try_malloc(sizeof(struct termios)))) {
+               sr_err("serial: %s: term malloc failed", __func__);
+               return NULL;
+       }
+
        tcgetattr(fd, term);
 
        return term;