check ptr before dereferencing it. Found by PVS-Studio
authorAlan T. DeKok <aland@freeradius.org>
Wed, 17 May 2017 15:51:44 +0000 (11:51 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 19 May 2017 18:06:53 +0000 (14:06 -0400)
src/lib/missing.c

index 22fea07..95b8c54 100644 (file)
@@ -321,10 +321,9 @@ HMAC_CTX *HMAC_CTX_new(void)
 {
        HMAC_CTX *ctx;
        ctx = OPENSSL_malloc(sizeof(*ctx));
+       if (!ctx) return NULL;
+
        memset(ctx, 0, sizeof(*ctx));
-       if (ctx == NULL) {
-                return NULL;
-        }
         HMAC_CTX_init(ctx);
        return ctx;
 }