summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio/ProjectTemplate.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-09-11 02:15:44 +0300
committerIdan Horowitz <idan.horowitz@gmail.com>2021-09-11 20:36:43 +0300
commit6704961c8250b44dc622e95821fd7e2b6bed673a (patch)
treebd540128659a2556acc51464552091fc3eb2e449 /Userland/DevTools/HackStudio/ProjectTemplate.cpp
parentaba4c9579ff8d36f739eb221e330782e5c3a5d9d (diff)
downloadserenity-6704961c8250b44dc622e95821fd7e2b6bed673a.zip
AK: Replace the mutable String::replace API with an immutable version
This removes the awkward String::replace API which was the only String API which mutated the String and replaces it with a new immutable version that returns a new String with the replacements applied. This also fixes a couple of UAFs that were caused by the use of this API. As an optimization an equivalent StringView::replace API was also added to remove an unnecessary String allocations in the format of: `String { view }.replace(...);`
Diffstat (limited to 'Userland/DevTools/HackStudio/ProjectTemplate.cpp')
-rw-r--r--Userland/DevTools/HackStudio/ProjectTemplate.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp
index 9cb202087e..619d042e5e 100644
--- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp
+++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp
@@ -90,8 +90,7 @@ Result<void, String> ProjectTemplate::create_project(const String& name, const S
dbgln("Running post-create script '{}'", postcreate_script_path);
// Generate a namespace-safe project name (replace hyphens with underscores)
- String namespace_safe(name.characters());
- namespace_safe.replace("-", "_", true);
+ auto namespace_safe = name.replace("-", "_", true);
pid_t child_pid;
const char* argv[] = { postcreate_script_path.characters(), name.characters(), path.characters(), namespace_safe.characters(), nullptr };