Fix a2i_ASN1_* leak on failure.

Caught by clang scan-build.

Change-Id: I1097848052026361e24fd1202cc0c831c3f83e49
Reviewed-on: https://boringssl-review.googlesource.com/2201
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/asn1/f_enum.c b/crypto/asn1/f_enum.c
index 5725824..530afe5 100644
--- a/crypto/asn1/f_enum.c
+++ b/crypto/asn1/f_enum.c
@@ -159,7 +159,6 @@
 			if (sp == NULL)
 				{
 				OPENSSL_PUT_ERROR(ASN1, a2i_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE);
-				if (s != NULL) OPENSSL_free(s);
 				goto err;
 				}
 			s=sp;
@@ -200,6 +199,8 @@
 err_sl:
 		OPENSSL_PUT_ERROR(ASN1, a2i_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
 		}
+	if (s != NULL)
+		OPENSSL_free(s);
 	return(ret);
 	}
 
diff --git a/crypto/asn1/f_int.c b/crypto/asn1/f_int.c
index 7b8c61a..2c4fe6f 100644
--- a/crypto/asn1/f_int.c
+++ b/crypto/asn1/f_int.c
@@ -163,7 +163,6 @@
 			if (sp == NULL)
 				{
 				OPENSSL_PUT_ERROR(ASN1, a2i_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
-				if (s != NULL) OPENSSL_free(s);
 				goto err;
 				}
 			s=sp;
@@ -204,6 +203,8 @@
 err_sl:
 		OPENSSL_PUT_ERROR(ASN1, a2i_ASN1_INTEGER, ASN1_R_SHORT_LINE);
 		}
+	if (s != NULL)
+		OPENSSL_free(s);
 	return(ret);
 	}
 
diff --git a/crypto/asn1/f_string.c b/crypto/asn1/f_string.c
index d6f128d..2f53670 100644
--- a/crypto/asn1/f_string.c
+++ b/crypto/asn1/f_string.c
@@ -157,7 +157,6 @@
 			if (sp == NULL)
 				{
 				OPENSSL_PUT_ERROR(ASN1, a2i_ASN1_STRING, ERR_R_MALLOC_FAILURE);
-				if (s != NULL) OPENSSL_free(s);
 				goto err;
 				}
 			s=sp;
@@ -198,6 +197,8 @@
 err_sl:
 		OPENSSL_PUT_ERROR(ASN1, a2i_ASN1_STRING, ASN1_R_SHORT_LINE);
 		}
+	if (s != NULL)
+		OPENSSL_free(s);
 	return(ret);
 	}