diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c
index 191cfef1a..7911c4bda 100644
--- a/crypto/x509v3/v3_utl.c
+++ b/crypto/x509v3/v3_utl.c
@@ -826,13 +826,13 @@ int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk,
 				break;
 				}
 #ifndef CHARSET_EBCDIC
-			if (*p == '+')
+		if (*type == '+')
 #else
-			if (*p == os_toascii['+'])
+		if (*type == os_toascii['+'])
 #endif
 			{
 			mval = -1;
-			p++;
+			type++;
 			}
 		else
 			mval = 0;