[vlc-commits] lua: fix opening of scripts on Windows on non-ASCII path

Jean-Baptiste Kempf git at videolan.org
Tue Feb 10 15:21:05 CET 2015


vlc/vlc-2.2 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Feb 10 14:51:51 2015 +0100| [fb43d3276ed15baa46cc9c702748978bec067ae0] | committer: Jean-Baptiste Kempf

lua: fix opening of scripts on Windows on non-ASCII path

Close #13752

(cherry picked from commit e105c631feec9c7a359002d1c44c8b919d55eb23)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/lua/vlc.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index aa0e361..dd8987b 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -835,15 +835,23 @@ int vlclua_add_modules_path( lua_State *L, const char *psz_filename )
 }
 
 /** Replacement for luaL_dofile, using VLC's input capabilities */
-int vlclua_dofile( vlc_object_t *p_this, lua_State *L, const char *uri )
+int vlclua_dofile( vlc_object_t *p_this, lua_State *L, const char *curi )
 {
-    if( !strstr( uri, "://" ) )
-        return luaL_dofile( L, uri );
-    if( !strncasecmp( uri, "file://", 7 ) )
-        return luaL_dofile( L, uri + 7 );
+    char *uri = ToLocaleDup( curi );
+    if( !strstr( uri, "://" ) ) {
+        int ret = luaL_dofile( L, uri );
+        free( uri );
+        return ret;
+    }
+    if( !strncasecmp( uri, "file://", 7 ) ) {
+        int ret = luaL_dofile( L, uri + 7 );
+        free( uri );
+        return ret;
+    }
     stream_t *s = stream_UrlNew( p_this, uri );
     if( !s )
     {
+        free( uri );
         return 1;
     }
     int64_t i_size = stream_Size( s );
@@ -852,6 +860,7 @@ int vlclua_dofile( vlc_object_t *p_this, lua_State *L, const char *uri )
     {
         // FIXME: read the whole stream until we reach the end (if no size)
         stream_Delete( s );
+        free( uri );
         return 1;
     }
     int64_t i_read = stream_Read( s, p_buffer, (int) i_size );
@@ -862,5 +871,6 @@ int vlclua_dofile( vlc_object_t *p_this, lua_State *L, const char *uri )
         i_ret = lua_pcall( L, 0, LUA_MULTRET, 0 );
     stream_Delete( s );
     free( p_buffer );
+    free( uri );
     return i_ret;
 }



More information about the vlc-commits mailing list