From 269de3533ac58de85bf874afcbc862d73e1944c7 Mon Sep 17 00:00:00 2001 From: Stefan Tauner Date: Tue, 12 Jul 2011 22:35:21 +0000 Subject: Fix unchecked malloc calls and casts of malloc return values In the long term the exit calls should be replaced by returns. until then this is the correct way to handle failures. the casts are not needed (in C) and we don't cast malloc return values anywhere else. Corresponding to flashrom svn r1370. Signed-off-by: Stefan Tauner Acked-by: Uwe Hermann --- serial.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'serial.c') diff --git a/serial.c b/serial.c index 5cc2fe0..b504974 100644 --- a/serial.c +++ b/serial.c @@ -110,6 +110,8 @@ fdtype sp_openserport(char *dev, unsigned int baud) (tolower((unsigned char)dev[1]) == 'o') && (tolower((unsigned char)dev[2]) == 'm')) { dev2 = malloc(strlen(dev) + 5); + if (!dev2) + sp_die("Error: Out of memory"); strcpy(dev2, "\\\\.\\"); strcpy(dev2 + 4, dev); } -- cgit v1.1