From 6b574175dd43735a26f171de6b34c3f15bb50f12 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 22 Feb 2011 11:31:32 -0800 Subject: Prevent the default message from getting mutated. If a Lua program references the default message, it will be copied into a mutable object. --- lang_ext/lua/test.lua | 12 +++++++----- lang_ext/lua/upb.c | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'lang_ext') diff --git a/lang_ext/lua/test.lua b/lang_ext/lua/test.lua index 978fb11..67c955e 100644 --- a/lang_ext/lua/test.lua +++ b/lang_ext/lua/test.lua @@ -23,15 +23,17 @@ SpeedMessage1 = symtab:lookup("benchmarks.SpeedMessage1") print(SpeedMessage1:name()) msg = SpeedMessage1() --- print(msg.field1) +--print(msg.field1) -- print(msg.field129) -- print(msg.field271) --- print(msg.field15.field15) +print(msg.field15.field15) +msg.field15.field15 = "my override" +print(msg.field15.field15) -- print(msg.field1) -- print(msg.field1) -- msg.field1 = "YEAH BABY!" -- print(msg.field1) -print(msg.field129) -msg.field129 = 5 -print(msg.field129) +-- print(msg.field129) +-- msg.field129 = 5 +-- print(msg.field129) diff --git a/lang_ext/lua/upb.c b/lang_ext/lua/upb.c index 460ac86..2e0102e 100644 --- a/lang_ext/lua/upb.c +++ b/lang_ext/lua/upb.c @@ -170,7 +170,7 @@ static void lupb_pushvalue(lua_State *L, upb_value val, upb_fielddef *f) { static upb_value lupb_getvalue(lua_State *L, int narg, upb_fielddef *f) { upb_value val; - lua_Number num; + lua_Number num = 0; if (!upb_issubmsg(f) && !upb_isstring(f) && f->type != UPB_TYPE(BOOL)) { num = luaL_checknumber(L, narg); if (f->type != UPB_TYPE(DOUBLE) && f->type != UPB_TYPE(FLOAT) && -- cgit v1.2.3