If the first serializer we find is the desired one that's ok
[openssl.git] / crypto / serializer / serializer_pkey.c
index 3f1eb58..4b1bf5c 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);
         }