Index: runtime/bin/utils_win.cc |
diff --git a/runtime/bin/utils_win.cc b/runtime/bin/utils_win.cc |
index 7e3cfb689a7caf953365ca083faf72e9569070d5..4b0b1fa01e707a20d80d35fd3637990f915a8b98 100644 |
--- a/runtime/bin/utils_win.cc |
+++ b/runtime/bin/utils_win.cc |
@@ -159,6 +159,23 @@ const wchar_t* StringUtilsWin::Utf8ToWide( |
} |
+char* StringUtils::StrNDup(const char* s, intptr_t n) { |
+ intptr_t len = strlen(s); |
+ if ((n < 0) || (len < 0)) { |
+ return NULL; |
+ } |
+ if (n < len) { |
+ len = n; |
+ } |
+ char* result = reinterpret_cast<char*>(malloc(len + 1)); |
+ if (result == NULL) { |
+ return NULL; |
+ } |
+ result[len] = '\0'; |
+ return reinterpret_cast<char*>(memmove(result, s, len)); |
+} |
+ |
+ |
bool ShellUtils::GetUtf8Argv(int argc, char** argv) { |
wchar_t* command_line = GetCommandLineW(); |
int unicode_argc; |