[vlc-commits] test/keystore: fix infinite loop when failing from dialog

Thomas Guillem git at videolan.org
Mon Jan 23 10:22:22 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jan 23 10:04:49 2017 +0100| [ca160e39d7fc227cebee17491eebe8705bc7663c] | committer: Thomas Guillem

test/keystore: fix infinite loop when failing from dialog

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ca160e39d7fc227cebee17491eebe8705bc7663c
---

 test/src/misc/keystore.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/test/src/misc/keystore.c b/test/src/misc/keystore.c
index ac57f61..aadd763 100644
--- a/test/src/misc/keystore.c
+++ b/test/src/misc/keystore.c
@@ -199,6 +199,12 @@ static const struct testcase
       { "user1", "pwd1" }, {}, { "user1", "pwd1" }, false },
 };
 
+struct dialog_ctx
+{
+    bool b_abort;
+    const struct testcase *p_test;
+};
+
 static void
 display_login_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
                  const char *psz_text, const char *psz_default_username,
@@ -208,13 +214,18 @@ display_login_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
     (void) psz_text;
     (void) psz_default_username;
     (void) b_ask_store;
-    struct testcase *p_testcase = p_data;
+    struct dialog_ctx *p_dialog_ctx = p_data;
+    const struct testcase *p_testcase = p_dialog_ctx->p_test;
 
     const char *psz_user = p_testcase->dialog.psz_user != NULL ?
                            p_testcase->dialog.psz_user : psz_default_username;
-    if (psz_user != NULL && p_testcase->dialog.psz_pwd != NULL)
+    if (!p_dialog_ctx->b_abort && psz_user != NULL
+     && p_testcase->dialog.psz_pwd != NULL)
+    {
         vlc_dialog_id_post_login(p_id, psz_user, p_testcase->dialog.psz_pwd,
                                  p_testcase->b_dialog_store);
+        p_dialog_ctx->b_abort = true;
+    }
     else
         vlc_dialog_id_dismiss(p_id);
 }
@@ -240,7 +251,11 @@ test(vlc_object_t *p_obj, unsigned int i_id, const struct testcase *p_test)
         .pf_display_login = display_login_cb,
         .pf_cancel = cancel_cb,
     };
-    vlc_dialog_provider_set_callbacks(p_obj, &cbs, (void *)p_test);
+    struct dialog_ctx dialog_ctx = {
+        .b_abort = false,
+        .p_test = p_test,
+    };
+    vlc_dialog_provider_set_callbacks(p_obj, &cbs, &dialog_ctx);
 
     const char *psz_opt_user = NULL, *psz_opt_pwd = NULL;
     if (p_test->opt.psz_user != NULL)



More information about the vlc-commits mailing list