serial.c: Use g_try_malloc().

This commit is contained in:
Uwe Hermann 2011-04-16 16:07:28 +02:00
parent 12ad53f5a6
commit c548332c21
1 changed files with 6 additions and 1 deletions

View File

@ -163,7 +163,12 @@ void *serial_backup_params(int fd)
#else #else
struct termios *term; 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); tcgetattr(fd, term);
return term; return term;