[vlc-commits] input/control: UpdateBookmarksOption: prevent exessive bookmark-options

Filip Roséen git at videolan.org
Thu May 18 21:23:06 CEST 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Thu May 18 14:17:54 2017 +0200| [cffd83c6e5f8869d4079474abe6e2aae9e543845] | committer: Jean-Baptiste Kempf

input/control: UpdateBookmarksOption: prevent exessive bookmark-options

If UpdateBookmarksOption is called more than once, where the generated
bookmark-variable string would be different, it will result in the
input_item_t having several entries for "bookmarks=".

This patch makes it so that we overwrite any existing entry if such is
available, instead of simply appending a new one.

fixes: #18338

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 src/input/control.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/input/control.c b/src/input/control.c
index 8d9ad24dd7..904dcc17a2 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -594,8 +594,26 @@ static void UpdateBookmarksOption( input_thread_t *p_input )
 
     if( vlc_memstream_close( &vstr ) == VLC_SUCCESS )
     {
-        input_item_AddOption( priv->p_item, vstr.ptr, VLC_INPUT_OPTION_UNIQUE );
-        free( vstr.ptr );
+        bool b_overwritten = false;
+
+        for( int i = 0; i < priv->p_item->i_options; ++i )
+        {
+            char** ppsz_option = &priv->p_item->ppsz_options[i];
+
+            if( strncmp( *ppsz_option, "bookmarks=", 10 ) == 0 )
+            {
+                free( *ppsz_option );
+                *ppsz_option = vstr.ptr;
+                b_overwritten = true;
+            }
+        }
+
+        if( !b_overwritten )
+        {
+            input_item_AddOption( priv->p_item, vstr.ptr,
+                                  VLC_INPUT_OPTION_UNIQUE );
+            free( vstr.ptr );
+        }
     }
 
     input_SendEventBookmark( p_input );



More information about the vlc-commits mailing list