Handle the default X.509 version explicitly.

This is a no-op, but relying on ASN1_INTEGER_get's internal handling of
NULL is confusing.

Change-Id: I49ab38c170d2f39fd3a4780b8c44b103a2ba4615
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45924
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/x509/x509_set.c b/crypto/x509/x509_set.c
index 5f17851..9193b20 100644
--- a/crypto/x509/x509_set.c
+++ b/crypto/x509/x509_set.c
@@ -62,6 +62,10 @@
 
 long X509_get_version(const X509 *x509)
 {
+    // The default version is v1(0).
+    if (x509->cert_info->version == NULL) {
+        return 0;
+    }
     return ASN1_INTEGER_get(x509->cert_info->version);
 }