From 247ac2a5242efc8316b112bd9647f46bd0bd4035 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 9 Jun 2021 09:30:18 +0200 Subject: [PATCH] Fixes --- radio/src/lua/lua_api.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/radio/src/lua/lua_api.h b/radio/src/lua/lua_api.h index 89192fb59..2860e470c 100644 --- a/radio/src/lua/lua_api.h +++ b/radio/src/lua/lua_api.h @@ -64,14 +64,14 @@ void luaInitThemesAndWidgets(); #define lua_pushtablenumber(L, k, v) (lua_pushstring(L, (k)), lua_pushnumber(L, (v)), lua_settable(L, -3)) // size based string (possibly no null-termination) -#define __lua_strncpy(s) \ - char tmp[sizeof(s) + 1]; \ - strncpy(tmp, (s), sizeof(s)); \ +#define __lua_strncpy(s) \ + char tmp[sizeof(s) + 1]; \ + strncpy(tmp, (s), sizeof(tmp) - 1); \ tmp[sizeof(s)] = '\0'; // size based string (possibly no null-termination) #define lua_pushnstring(L, s) { __lua_strncpy(s); lua_pushstring(L, tmp); } -#define lua_pushtablenstring(L, k, v) { __lua_strncpy(s); lua_pushstring(L, (k)); lua_pushstring(L, tmp); lua_settable(L, -3); } +#define lua_pushtablenstring(L, k, v) { __lua_strncpy(v); lua_pushstring(L, (k)); lua_pushstring(L, tmp); lua_settable(L, -3); } // null-terminated string #define lua_pushtablestring(L, k, v) (lua_pushstring(L, (k)), lua_pushstring(L, (v)), lua_settable(L, -3))