Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Side by Side Diff: runtime/bin/dartutils.cc

Issue 2383293003: - fix some cases where we are using uninitialized memory (Closed)
Patch Set: address self code review. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/platform/assert.h » ('j') | runtime/vm/native_entry.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/crypto.h" 7 #include "bin/crypto.h"
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/extensions.h" 9 #include "bin/extensions.h"
10 #include "bin/file.h" 10 #include "bin/file.h"
11 #include "bin/io_buffer.h" 11 #include "bin/io_buffer.h"
12 #include "bin/platform.h" 12 #include "bin/platform.h"
13 #include "bin/utils.h" 13 #include "bin/utils.h"
14 14
15 #include "include/dart_api.h" 15 #include "include/dart_api.h"
16 #include "include/dart_native_api.h" 16 #include "include/dart_native_api.h"
17 #include "include/dart_tools_api.h" 17 #include "include/dart_tools_api.h"
18 18
19 #include "platform/assert.h" 19 #include "platform/assert.h"
20 #include "platform/globals.h" 20 #include "platform/globals.h"
21 #include "platform/memory_sanitizer.h"
21 22
22 // Return the error from the containing function if handle is in error handle. 23 // Return the error from the containing function if handle is in error handle.
23 #define RETURN_IF_ERROR(handle) \ 24 #define RETURN_IF_ERROR(handle) \
24 { \ 25 { \
25 Dart_Handle __handle = handle; \ 26 Dart_Handle __handle = handle; \
26 if (Dart_IsError((__handle))) { \ 27 if (Dart_IsError((__handle))) { \
27 return __handle; \ 28 return __handle; \
28 } \ 29 } \
29 } 30 }
30 31
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 } 921 }
921 922
922 923
923 Dart_Handle DartUtils::NewError(const char* format, ...) { 924 Dart_Handle DartUtils::NewError(const char* format, ...) {
924 va_list args; 925 va_list args;
925 va_start(args, format); 926 va_start(args, format);
926 intptr_t len = vsnprintf(NULL, 0, format, args); 927 intptr_t len = vsnprintf(NULL, 0, format, args);
927 va_end(args); 928 va_end(args);
928 929
929 char* buffer = reinterpret_cast<char*>(Dart_ScopeAllocate(len + 1)); 930 char* buffer = reinterpret_cast<char*>(Dart_ScopeAllocate(len + 1));
931 MSAN_UNPOISON(buffer, (len + 1));
930 va_list args2; 932 va_list args2;
931 va_start(args2, format); 933 va_start(args2, format);
932 vsnprintf(buffer, (len + 1), format, args2); 934 vsnprintf(buffer, (len + 1), format, args2);
933 va_end(args2); 935 va_end(args2);
934 936
935 return Dart_NewApiError(buffer); 937 return Dart_NewApiError(buffer);
936 } 938 }
937 939
938 940
939 Dart_Handle DartUtils::NewInternalError(const char* message) { 941 Dart_Handle DartUtils::NewInternalError(const char* message) {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 new CObjectString(CObject::NewString(os_error->message())); 1265 new CObjectString(CObject::NewString(os_error->message()));
1264 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1266 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1265 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1267 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1266 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1268 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1267 result->SetAt(2, error_message); 1269 result->SetAt(2, error_message);
1268 return result; 1270 return result;
1269 } 1271 }
1270 1272
1271 } // namespace bin 1273 } // namespace bin
1272 } // namespace dart 1274 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/platform/assert.h » ('j') | runtime/vm/native_entry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698