Skip to content

Commit 2653a32

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[gen_snapshot] Escape paths when writing loading unit manifests.
Bug: #41974 Change-Id: I030629110026bbc4b1c339764ed805f65f753448 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154827 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 7032b2b commit 2653a32

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

runtime/bin/gen_snapshot.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
#include "bin/thread.h"
2525
#include "bin/utils.h"
2626
#include "bin/vmservice_impl.h"
27-
#include "platform/syslog.h"
2827

2928
#include "include/dart_api.h"
3029
#include "include/dart_tools_api.h"
3130

3231
#include "platform/globals.h"
3332
#include "platform/growable_array.h"
3433
#include "platform/hashmap.h"
34+
#include "platform/syslog.h"
35+
#include "platform/text_buffer.h"
3536

3637
namespace dart {
3738
namespace bin {
@@ -600,13 +601,14 @@ static File* OpenLoadingUnitManifest() {
600601
static void WriteLoadingUnitManifest(File* manifest_file,
601602
intptr_t id,
602603
const char* path) {
603-
bool success = true;
604+
TextBuffer line(128);
604605
if (id != 1) {
605-
success &= manifest_file->Print(",");
606+
line.Printf(",");
606607
}
607-
success &=
608-
manifest_file->Print("{ \"id\": %" Pd ", \"path\": \"%s\" }\n", id, path);
609-
if (!success) {
608+
line.Printf("{ \"id\": %" Pd ", \"path\": \"", id);
609+
line.AddEscapedString(path);
610+
line.Printf("\" }");
611+
if (!manifest_file->Print("%s\n", line.buf())) {
610612
PrintErrAndExit("Error: Unable to write file: %s\n\n",
611613
loading_unit_manifest_filename);
612614
}

0 commit comments

Comments
 (0)