diff --git a/src/lua/mysql.cc b/src/lua/mysql.cc
index e7628f5d22ffc68b06852bdf19a9691fab3c12fe..7e5cf8725806e1d85e5de1be74f730e48eb44169 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 2ac1c898cbfc916876e52b17d60a85ac597fec8f..86e286789722c9ec343c8c70691d4d002c8fdadf 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");