From ade8619ea65e415394f648a44b8350de40a17951 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 26 Jan 2016 19:33:46 +0100 Subject: [PATCH] Don't assume malloc sets errno to ENOMEM. Although many implementations (including glibc) set errno on failure, this is not required by the C standard. --- src/irda.c | 2 +- src/serial_posix.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/irda.c b/src/irda.c index b0ee69e..57b5076 100644 --- a/src/irda.c +++ b/src/irda.c @@ -83,7 +83,7 @@ irda_socket_open (irda_t **out, dc_context_t *context) #ifdef _WIN32 SYSERROR (context, ERROR_OUTOFMEMORY); #else - SYSERROR (context, errno); + SYSERROR (context, ENOMEM); #endif return -1; // ENOMEM (Not enough space) } diff --git a/src/serial_posix.c b/src/serial_posix.c index ffd4047..b67ddb7 100644 --- a/src/serial_posix.c +++ b/src/serial_posix.c @@ -137,7 +137,7 @@ serial_open (serial_t **out, dc_context_t *context, const char* name) // Allocate memory. serial_t *device = (serial_t *) malloc (sizeof (serial_t)); if (device == NULL) { - SYSERROR (context, errno); + SYSERROR (context, ENOMEM); return -1; // ENOMEM (Not enough space) }