[vlc-commits] [Git][videolan/vlc][master] 2 commits: dialog: only check vlc_killed() before displaying a dialog

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Oct 27 06:58:01 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
c8e430e7 by Alexandre Janniaux at 2026-10-27T07:23:25+01:00
dialog: only check vlc_killed() before displaying a dialog

get_dialog_provider() returned NULL for every caller when the calling
thread was killed. That is meant to prevent new dialogs from being shown
to the user when the thread is being interrupted.

But many of the calls were not made with the goal to interact with the
user. get_dialog_provider() had a parameter to determine whether
interaction was needed with the user or not but then the function would
still return NULL when the thread is killed.

Split the helper so that only the functions displaying a dialog check
no_interact and vlc_killed(), and fetch the provider unconditionally in
the others.

This basically extend 5d643c7b14c6bfa02adbe119af8668c43d9a1acc to every
other locations that matter.

Found using static analysis tools (sparrow) which reported missing null
checks for those occurrences.

- - - - -
082ec78b by Alexandre Janniaux at 2026-10-27T07:23:25+01:00
dialog: fix va_list usage on error

dialog_display_error_va() consumes the va_list. When vasprintf() fails,
vlc_dialog_display_error_va() reuses this va_list to log a message.
Duplicating the va_list avoids the misuage of the va_list.

- - - - -


1 changed file:

- src/interface/dialog.c


Changes:

=====================================
src/interface/dialog.c
=====================================
@@ -124,17 +124,22 @@ struct dialog_i11e_context
 };
 
 static inline vlc_dialog_provider *
-get_dialog_provider(vlc_object_t *p_obj, bool b_check_interact)
+get_dialog_provider(vlc_object_t *p_obj)
 {
-    if ((b_check_interact && p_obj->no_interact) || vlc_killed())
-        return NULL;
-
     vlc_dialog_provider *p_provider =
         libvlc_priv(vlc_object_instance(p_obj))->p_dialog_provider;
     assert(p_provider != NULL);
     return p_provider;
 }
 
+static inline vlc_dialog_provider *
+get_interactive_dialog_provider(vlc_object_t *p_obj)
+{
+    if (p_obj->no_interact || vlc_killed())
+        return NULL;
+    return get_dialog_provider(p_obj);
+}
+
 static void
 dialog_id_release(vlc_dialog_id *p_id)
 {
@@ -260,7 +265,7 @@ vlc_dialog_provider_set_callbacks(vlc_object_t *p_obj,
                                   const vlc_dialog_cbs *p_cbs, void *p_data)
 {
     assert(p_obj != NULL);
-    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj, false);
+    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj);
 
     vlc_mutex_lock(&p_provider->lock);
     dialog_clear_all_locked(p_provider);
@@ -284,7 +289,7 @@ vlc_dialog_provider_set_error_callback(vlc_object_t *p_obj,
                                   vlc_dialog_error_cbs p_cbs, void *p_data)
 {
     assert(p_obj != NULL);
-    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj, false);
+    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj);
 
     vlc_mutex_lock(&p_provider->lock);
 
@@ -384,10 +389,16 @@ vlc_dialog_display_error_va(vlc_object_t *p_obj, const char *psz_title,
 {
     assert(p_obj != NULL && psz_title != NULL && psz_fmt != NULL);
     int i_ret;
-    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj, true);
+    vlc_dialog_provider *p_provider = get_interactive_dialog_provider(p_obj);
 
     if (p_provider != NULL)
-        i_ret = dialog_display_error_va(p_provider, psz_title, psz_fmt, ap);
+    {
+        va_list ap_dialog;
+        va_copy(ap_dialog, ap);
+        i_ret = dialog_display_error_va(p_provider, psz_title, psz_fmt,
+                                        ap_dialog);
+        va_end(ap_dialog);
+    }
     else
         i_ret = VLC_EGENERIC;
 
@@ -458,7 +469,7 @@ vlc_dialog_wait_login_va(vlc_object_t *p_obj,  char **ppsz_username,
     assert(p_obj != NULL && ppsz_username != NULL && ppsz_password != NULL
         && psz_fmt != NULL && psz_title != NULL);
 
-    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj, true);
+    vlc_dialog_provider *p_provider = get_interactive_dialog_provider(p_obj);
     if (p_provider == NULL)
         return VLC_EGENERIC;
 
@@ -547,7 +558,7 @@ vlc_dialog_wait_question_va(vlc_object_t *p_obj,
     assert(p_obj != NULL && psz_fmt != NULL && psz_title != NULL
         && psz_cancel != NULL);
 
-    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj, true);
+    vlc_dialog_provider *p_provider = get_interactive_dialog_provider(p_obj);
     if (p_provider == NULL)
         return VLC_EGENERIC;
 
@@ -635,7 +646,7 @@ vlc_dialog_display_progress_va(vlc_object_t *p_obj, bool b_indeterminate,
 {
     assert(p_obj != NULL && psz_title != NULL && psz_fmt != NULL);
 
-    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj, true);
+    vlc_dialog_provider *p_provider = get_interactive_dialog_provider(p_obj);
     if (p_provider == NULL)
         return NULL;
     vlc_dialog_id *p_id;
@@ -666,7 +677,7 @@ dialog_update_progress(vlc_object_t *p_obj, vlc_dialog_id *p_id, float f_value,
                        char *psz_text)
 {
     assert(p_obj != NULL && p_id != NULL);
-    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj, false);
+    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj);
 
     vlc_mutex_lock(&p_provider->lock);
     if (p_provider->cbs.pf_update_progress == NULL ||
@@ -732,13 +743,7 @@ void
 vlc_dialog_release(vlc_object_t *p_obj, vlc_dialog_id *p_id)
 {
     assert(p_obj != NULL && p_id != NULL);
-    /* We can't use get_dialog_provider here because when vlc_killed is true,
-     * get_dialog_provider returns NULL, and we can't release the dialog
-     * properly. Moreover, since the dialog has been created by the provider,
-     * we can be sure that one exists. */
-    vlc_dialog_provider *p_provider =
-        libvlc_priv(vlc_object_instance(p_obj))->p_dialog_provider;
-    assert(p_provider != NULL);
+    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj);
 
     vlc_mutex_lock(&p_provider->lock);
     dialog_cancel_locked(p_provider, p_id);
@@ -856,7 +861,7 @@ vlc_dialog_provider_set_ext_callback(vlc_object_t *p_obj,
                                      void *p_data)
 {
     assert(p_obj != NULL);
-    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj, false);
+    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj);
 
     vlc_mutex_lock(&p_provider->lock);
 
@@ -871,7 +876,7 @@ int
 vlc_ext_dialog_update(vlc_object_t *p_obj, extension_dialog_t *p_ext_dialog)
 {
     assert(p_obj != NULL);
-    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj, false);
+    vlc_dialog_provider *p_provider = get_dialog_provider(p_obj);
 
     vlc_mutex_lock(&p_provider->lock);
     if (p_provider->pf_ext_update == NULL)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2384e64adf6a253098a37a5105834d53cd458624...082ec78be256c50a32aaf1a60023de303dbc1e71

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2384e64adf6a253098a37a5105834d53cd458624...082ec78be256c50a32aaf1a60023de303dbc1e71
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list