From 48c1ae929e6eda55b2ef8ce1841d91c1d4581a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 6 Apr 2018 20:58:17 +0200 Subject: [PATCH] libroot: avoid excessive stack usage in __find_directory() create_path() is inlined in __find_directory(). --- src/system/libroot/os/find_directory.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/system/libroot/os/find_directory.cpp b/src/system/libroot/os/find_directory.cpp index 6ee1ca22df..0b944e80a3 100644 --- a/src/system/libroot/os/find_directory.cpp +++ b/src/system/libroot/os/find_directory.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -195,13 +196,14 @@ static const char *kUserDirectories[] = { static int create_path(const char *path, mode_t mode) { - char buffer[B_PATH_NAME_LENGTH + 1]; int pathLength; int i = 0; if (path == NULL || ((pathLength = strlen(path)) > B_PATH_NAME_LENGTH)) return EINVAL; + BStackOrHeapArray buffer(pathLength + 1); + while (++i < pathLength) { char *slash = strchr(&path[i], '/'); struct stat st;