From d0c03bba25acfa9fd58f52ae52ef0f7463ccc998 Mon Sep 17 00:00:00 2001 From: "Dmitry E. Oboukhov" <unera@debian.org> Date: Thu, 13 Jun 2013 16:34:13 +0400 Subject: [PATCH] Drop alloca from exception. Throw only by static strings. --- src/lua/mysql.cc | 2 -- src/lua/pg.cc | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lua/mysql.cc b/src/lua/mysql.cc index e7628f5d22..7e5cf87258 100644 --- a/src/lua/mysql.cc +++ b/src/lua/mysql.cc @@ -381,8 +381,6 @@ lbox_net_mysql_connect(struct lua_State *L) if (*mysql_error(mysql)) { const char *estr = mysql_error(mysql); - char *b = (char *)alloca(strlen(estr) + 1); - strcpy(b, estr); mysql_close(mysql); luaL_error(L, "%s", estr); } diff --git a/src/lua/pg.cc b/src/lua/pg.cc index 2ac1c898cb..86e2867897 100644 --- a/src/lua/pg.cc +++ b/src/lua/pg.cc @@ -396,11 +396,9 @@ lbox_net_pg_connect(struct lua_State *L) lua_pop(L, 1); if (PQstatus(conn) != CONNECTION_OK) { - char *msg = (typeof(msg)) - alloca(strlen(PQerrorMessage(conn)) + 1); - strcpy(msg, PQerrorMessage(conn)); + const char *msg = PQerrorMessage(conn); PQfinish(conn); - luaL_error(L, constr); + luaL_error(L, "%s", msg); } lua_pushstring(L, "raw"); -- GitLab