summaryrefslogtreecommitdiffstats
path: root/src/msvc_helper_main-win32.cc
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2013-08-19 23:44:16 (GMT)
committerReid Kleckner <rnk@google.com>2013-08-19 23:44:16 (GMT)
commit808ba411d4484617363b79f175569d6ae2f86c01 (patch)
tree71026af7a60a6e1e61e16d974862dd5c059b2297 /src/msvc_helper_main-win32.cc
parent3913d73e2025555d84f72a7c2d9b31b300535900 (diff)
downloadNinja-808ba411d4484617363b79f175569d6ae2f86c01.zip
Ninja-808ba411d4484617363b79f175569d6ae2f86c01.tar.gz
Ninja-808ba411d4484617363b79f175569d6ae2f86c01.tar.bz2
Avoid indexing into an empty string.
Diffstat (limited to 'src/msvc_helper_main-win32.cc')
-rw-r--r--src/msvc_helper_main-win32.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/msvc_helper_main-win32.cc b/src/msvc_helper_main-win32.cc
index ff9bc8e..e3a7846 100644
--- a/src/msvc_helper_main-win32.cc
+++ b/src/msvc_helper_main-win32.cc
@@ -126,12 +126,15 @@ int MSVCHelperMain(int argc, char** argv) {
WriteDepFileOrDie(output_filename, parser);
}
+ if (output.empty())
+ return exit_code;
+
// CLWrapper's output already as \r\n line endings, make sure the C runtime
// doesn't expand this to \r\r\n.
_setmode(_fileno(stdout), _O_BINARY);
// Avoid printf and C strings, since the actual output might contain null
// bytes like UTF-16 does (yuck).
- fwrite(&output[0], sizeof(char), output.size(), stdout);
+ fwrite(&output[0], 1, output.size(), stdout);
return exit_code;
}