If the first serializer we find is the desired one that's ok
authorMatt Caswell <matt@openssl.org>
Fri, 6 Mar 2020 18:05:37 +0000 (18:05 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 11 Mar 2020 15:07:00 +0000 (15:07 +0000)
Stop looking for a desired serializer if the first one is desired.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11271)

crypto/serializer/serializer_pkey.c

index 3f1eb5851a2ded677c7419fd371b2cc5a2170bd2..4b1bf5c3ee1d62a447097c2aab434d63f33f1dbb 100644 (file)
@@ -121,13 +121,13 @@ static void select_serializer(const char *name, void *data)
         return;
 
     if ((s = OSSL_SERIALIZER_fetch(d->libctx, name, d->propquery)) != NULL) {
-        if (d->first == NULL && s->serialize_data != NULL) {
-            d->first = s;
-        } else if (OSSL_SERIALIZER_provider(s) == d->desired_provider
-                   && s->serialize_object != NULL) {
+        if (OSSL_SERIALIZER_provider(s) == d->desired_provider
+                && s->serialize_object != NULL) {
             OSSL_SERIALIZER_free(d->first);
             d->first = NULL;
             d->desired = s;
+        } else if (d->first == NULL && s->serialize_data != NULL) {
+            d->first = s;
         } else {
             OSSL_SERIALIZER_free(s);
         }