RSA, DSA, DH: Allow some given input to be NULL on already initialised keys
[openssl.git] / crypto / ui / ui_lib.c
index 0823ae880cac1a5a61d22312683cf82248e41f8b..7b08107f7a46ff2c69f6070a2ae3231b879adb47 100644 (file)
@@ -79,6 +79,14 @@ UI *UI_new_method(const UI_METHOD *method)
         UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
+
+    ret->lock = CRYPTO_THREAD_lock_new();
+    if (ret->lock == NULL) {
+        UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);
+        OPENSSL_free(ret);
+        return NULL;
+    }
+
     if (method == NULL)
         ret->meth = UI_get_default_method();
     else
@@ -111,6 +119,7 @@ void UI_free(UI *ui)
         return;
     sk_UI_STRING_pop_free(ui->strings, free_string);
     CRYPTO_free_ex_data(CRYPTO_EX_INDEX_UI, ui, &ui->ex_data);
+    CRYPTO_THREAD_lock_free(ui->lock);
     OPENSSL_free(ui);
 }
 
@@ -163,7 +172,7 @@ static int general_allocate_string(UI *ui, const char *prompt,
             s->_.string_data.result_maxsize = maxsize;
             s->_.string_data.test_buf = test_buf;
             ret = sk_UI_STRING_push(ui->strings, s);
-            /* sk_push() returns 0 on error.  Let's addapt that */
+            /* sk_push() returns 0 on error.  Let's adapt that */
             if (ret <= 0)
                 ret--;
         } else
@@ -207,7 +216,7 @@ static int general_allocate_boolean(UI *ui,
                 s->_.boolean_data.cancel_chars = cancel_chars;
                 ret = sk_UI_STRING_push(ui->strings, s);
                 /*
-                 * sk_push() returns 0 on error. Let's addapt that
+                 * sk_push() returns 0 on error. Let's adapt that
                  */
                 if (ret <= 0)
                     ret--;