This is an automated email from the ASF dual-hosted git repository.

jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b712f4  THRIFT-5106: Fix various Lua library and compiler issues 
Client: lua Patch: Jeffrey Han
7b712f4 is described below

commit 7b712f42d7bc03610511abd397845983deafa258
Author: Jeffrey Han <[email protected]>
AuthorDate: Thu Feb 20 14:18:23 2020 -0800

    THRIFT-5106: Fix various Lua library and compiler issues
    Client: lua
    Patch: Jeffrey Han
    
    This closes #2014
---
 compiler/cpp/src/thrift/generate/t_lua_generator.cc | 3 +++
 lib/lua/TCompactProtocol.lua                        | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/compiler/cpp/src/thrift/generate/t_lua_generator.cc 
b/compiler/cpp/src/thrift/generate/t_lua_generator.cc
index e6432c8..f858562 100644
--- a/compiler/cpp/src/thrift/generate/t_lua_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_lua_generator.cc
@@ -197,6 +197,9 @@ void t_lua_generator::close_generator() {
  * Generate a typedef (essentially a constant)
  */
 void t_lua_generator::generate_typedef(t_typedef* ttypedef) {
+  if (ttypedef->get_type()->get_name().empty()) {
+    return;
+  }
   f_types_ << endl << endl << indent() << ttypedef->get_symbolic() << " = "
            << ttypedef->get_type()->get_name();
 }
diff --git a/lib/lua/TCompactProtocol.lua b/lib/lua/TCompactProtocol.lua
index 7b75967..8e7db8e 100644
--- a/lib/lua/TCompactProtocol.lua
+++ b/lib/lua/TCompactProtocol.lua
@@ -314,10 +314,10 @@ end
 
 function TCompactProtocol:readMapBegin()
   local size = self:readVarint32()
-  if size < 0 then
-    return nil,nil,nil
+  local kvtype = 0
+  if size > 0 then
+    kvtype = self:readSignByte()
   end
-  local kvtype = self:readSignByte()
   local ktype = self:getTType(libluabitwise.shiftr(kvtype, 4))
   local vtype = self:getTType(kvtype)
   return ktype, vtype, size
@@ -426,7 +426,7 @@ function TCompactProtocol:readVarint64()
   local data = result(0)
   local shiftl = 0
   while true do
-    b = self:readByte()
+    b = self:readSignByte()
     endFlag, data = libluabpack.fromVarint64(b, shiftl, data)
     shiftl = shiftl + 7
     if endFlag == 0 then

Reply via email to