diff --git a/src/box/space.cc b/src/box/space.cc
index 304324d0a01d7f1d36a389144465b983b09f4d90..fbff6095e91c71368684d31944a08b3a96067ce6 100644
--- a/src/box/space.cc
+++ b/src/box/space.cc
@@ -488,8 +488,13 @@ check_spaces(struct tarantool_cfg *conf)
 
 		/* Check for index field type conflicts */
 		if (max_key_fieldno > 0) {
-			char *types = (char *) alloca(max_key_fieldno);
-			memset(types, 0, max_key_fieldno);
+			enum field_type *types = (enum field_type *)
+				calloc(1, sizeof(*types) * max_key_fieldno);
+			if (types == NULL) {
+				out_warning(CNF_OK, "cannot allocate %zd bytes",
+					    max_key_fieldno);
+				return -1;
+			}
 			for (size_t j = 0; space->index[j] != NULL; ++j) {
 				auto index = space->index[j];
 				for (size_t k = 0; index->key_field[k] != NULL; ++k) {
@@ -506,12 +511,15 @@ check_spaces(struct tarantool_cfg *conf)
 						} else {
 							out_warning(CNF_OK, "(space = %zu fieldno = %zu) "
 								    "index field type mismatch", i, f);
+							free(types);
 							return -1;
 						}
 					}
 				}
 
 			}
+
+			free(types);
 		}
 	}
 
diff --git a/src/log_io.cc b/src/log_io.cc
index 6db09b16d9e7cab2ec6a5dcaa62d7e211c795680..9dfc387090d02fc644ce6bd824bd1bdfbc6926d1 100644
--- a/src/log_io.cc
+++ b/src/log_io.cc
@@ -388,7 +388,7 @@ int
 inprogress_log_rename(struct log_io *l)
 {
 	char *filename = l->filename;
-	char *new_filename;
+	char new_filename[PATH_MAX];
 	char *suffix = strrchr(filename, '.');
 
 	assert(l->is_inprogress);
@@ -396,7 +396,6 @@ inprogress_log_rename(struct log_io *l)
 	assert(strcmp(suffix, inprogress_suffix) == 0);
 
 	/* Create a new filename without '.inprogress' suffix. */
-	new_filename = (char *) alloca(suffix - filename + 1);
 	memcpy(new_filename, filename, suffix - filename);
 	new_filename[suffix - filename] = '\0';
 
diff --git a/src/plugin/pg/pg.cc b/src/plugin/pg/pg.cc
index eed46c7d748032bac7a18f6af8c89312498e4477..b8958faf7d632f4feb4d947d30ae7455168dcd17 100644
--- a/src/plugin/pg/pg.cc
+++ b/src/plugin/pg/pg.cc
@@ -81,7 +81,6 @@ lua_check_pgconn(struct lua_State *L, int index)
 	return conn;
 }
 
-
 /** do execute request (is run in the other thread) */
 static ssize_t
 pg_exec(va_list ap)
@@ -210,14 +209,19 @@ lua_pg_execute(struct lua_State *L)
 	Oid *paramTypes = NULL;
 
 	if (count > 0) {
-		paramValues = (typeof(paramValues))
-			alloca( count * sizeof(*paramValues) );
-		paramLengths = (typeof(paramLengths))
-			alloca( count * sizeof(*paramLengths) );
-		paramFormats = (typeof(paramFormats))
-			alloca( count * sizeof(*paramFormats) );
-		paramTypes = (typeof(paramTypes))
-			alloca( count * sizeof(*paramTypes) );
+		/* Allocate memory for params using lua_newuserdata */
+		char *buf = (char *) lua_newuserdata(L, count *
+			(sizeof(*paramValues) + sizeof(*paramLengths) +
+			 sizeof(*paramFormats) + sizeof(*paramTypes)));
+
+		paramValues = (const char **) buf;
+		buf += count * sizeof(*paramValues);
+		paramLengths = (int *) buf;
+		buf += count * sizeof(*paramLengths);
+		paramFormats = (int *) buf;
+		buf += count * sizeof(*paramFormats);
+		paramTypes = (Oid *) buf;
+		buf += count * sizeof(*paramTypes);
 
 		for(int i = 0, idx = 3; i < count; i++, idx++) {
 			if (lua_isnil(L, idx)) {
@@ -288,6 +292,7 @@ lua_pg_execute(struct lua_State *L)
 	auto scope_guard = make_scoped_guard([&]{
 		PQclear(res);
 	});
+	lua_settop(L, 0);
 	return lua_push_pgres(L, res);
 }