Fix use after free bug.
authorIstvan Noszticzius <istvan.noszticzius@oracle.com>
Fri, 15 Aug 2014 15:43:28 +0000 (16:43 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 15 Aug 2014 15:46:14 +0000 (16:46 +0100)
Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 5afa57fb7b17aa51cfba1ffa94e900fc7a5f0e04)

crypto/x509v3/v3_utl.c

index 75efd9912aef29f5bd23402507b8441526210231..10a7aa876aa4ed472bc36a45377a5635e7330086 100644 (file)
@@ -879,9 +879,9 @@ static int do_check_string(ASN1_STRING *a, int cmp_type, equal_fn equal,
                if (astrlen < 0)
                        return -1;
                rv = equal(astr, astrlen, (unsigned char *)b, blen, flags);
-               OPENSSL_free(astr);
                if (rv > 0 && peername)
                        *peername = BUF_strndup((char *)astr, astrlen);
+               OPENSSL_free(astr);
                }
        return rv;
        }