Switched order of storing x509_req_names to match inputed order
diff --git a/library/x509write.c b/library/x509write.c
index 213add6..3302636 100644
--- a/library/x509write.c
+++ b/library/x509write.c
@@ -76,7 +76,7 @@
char *end = s + strlen( s );
char *oid = NULL;
int in_tag = 1;
- x509_req_name *cur = ctx->subject;
+ x509_req_name *cur;
while( ctx->subject )
{
@@ -121,15 +121,7 @@
goto exit;
}
- if( cur == NULL )
- {
- ctx->subject = cur = polarssl_malloc( sizeof(x509_req_name) );
- }
- else
- {
- cur->next = polarssl_malloc( sizeof(x509_req_name) );
- cur = cur->next;
- }
+ cur = polarssl_malloc( sizeof(x509_req_name) );
if( cur == NULL )
{
@@ -139,6 +131,9 @@
memset( cur, 0, sizeof(x509_req_name) );
+ cur->next = ctx->subject;
+ ctx->subject = cur;
+
strncpy( cur->oid, oid, strlen( oid ) );
strncpy( cur->name, s, c - s );