From: Uwe Hermann Date: Sat, 16 Apr 2011 14:07:28 +0000 (+0200) Subject: serial.c: Use g_try_malloc(). X-Git-Tag: libsigrok-0.1.0~281 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c548332c21acc2588114214b38eaa3237fc3f8b3;p=libsigrok.git serial.c: Use g_try_malloc(). --- diff --git a/hardware/common/serial.c b/hardware/common/serial.c index 5205c188..b98d3c95 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -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;