[vlc-devel] [PATCH] Return LUA "nul" when vlc.strings.from_charset returns error

Edward Wang edward.c.wang at compdigitec.com
Mon Jan 9 21:39:34 CET 2012


Return "nil" when native FromCharset fails instead of blank string.

Close #4815

---
 modules/lua/libs/strings.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/lua/libs/strings.c b/modules/lua/libs/strings.c
index 88c5f0e..ddf9eb9 100644
--- a/modules/lua/libs/strings.c
+++ b/modules/lua/libs/strings.c
@@ -139,8 +139,12 @@ static int vlclua_from_charset( lua_State *L )
 
     const char *psz_charset = luaL_checkstring( L, 1 );
     char *psz_output = FromCharset( psz_charset, psz_input, i_in_bytes );
-    lua_pushstring( L, psz_output ? psz_output : "" );
-    free( psz_output );
+    if( psz_output == NULL ) {
+        lua_pushnil( L );
+    } else {
+        lua_pushstring( L, psz_output );
+        free( psz_output );
+    }
     return 1;
 }
 
-- 
1.7.5.4




More information about the vlc-devel mailing list