From: Simon Josefsson Date: Thu, 24 Nov 2011 13:48:37 +0000 (+0100) Subject: Check calloc return value when creating errno varibles. X-Git-Tag: v1.6.2~1 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47c0514d6be9719c420b5f67e955b5784b07439b;p=yubikey-personalization.old Check calloc return value when creating errno varibles. --- diff --git a/ykcore/ykcore.c b/ykcore/ykcore.c index 80a1a23..10fb39b 100644 --- a/ykcore/ykcore.c +++ b/ykcore/ykcore.c @@ -250,8 +250,13 @@ int * const _yk_errno_location(void) if (tsd_init == 0) { if ((rc = YK_TSD_INIT(errno_key, free)) == 0) { - YK_TSD_SET(errno_key, calloc(1, sizeof(int))); - tsd_init = 1; + void *p = calloc(1, sizeof(int)); + if (!p) { + tsd_init = -1; + } else { + YK_TSD_SET(errno_key, p); + tsd_init = 1; + } } else { tsd_init = -1; } diff --git a/ykpers.c b/ykpers.c index c06ebbc..760941b 100644 --- a/ykpers.c +++ b/ykpers.c @@ -722,8 +722,13 @@ int * const _ykp_errno_location(void) if (tsd_init == 0) { if ((rc = YK_TSD_INIT(errno_key, free)) == 0) { - YK_TSD_SET(errno_key, calloc(1, sizeof(int))); - tsd_init = 1; + void *p = calloc(1, sizeof(int)); + if (!p) { + tsd_init = -1; + } else { + YK_TSD_SET(errno_key, p); + tsd_init = 1; + } } else { tsd_init = -1; }