]> err.no Git - yubikey-personalization.old/commitdiff
Check calloc return value when creating errno varibles.
authorSimon Josefsson <simon@josefsson.org>
Thu, 24 Nov 2011 13:48:37 +0000 (14:48 +0100)
committerSimon Josefsson <simon@josefsson.org>
Thu, 24 Nov 2011 13:48:37 +0000 (14:48 +0100)
ykcore/ykcore.c
ykpers.c

index 80a1a2388e66d0cf023c7261ff788545dec6f3bf..10fb39b73a53db90580ed16c7628a4a121cdcd8e 100644 (file)
@@ -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;
                }
index c06ebbcaa8a7d842822dafe66c4fac4fe6bec77e..760941bc08b2ec0dce84016954a65b06cca209e3 100644 (file)
--- 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;
                }