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

Unified Diff: third_party/crashpad/crashpad/util/win/process_info.cc

Issue 2688583002: Update Crashpad to 6af23a933a0dc10cda072570cc02efcd03488a90 (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/crashpad/crashpad/util/win/process_info.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/crashpad/crashpad/util/win/process_info.cc
diff --git a/third_party/crashpad/crashpad/util/win/process_info.cc b/third_party/crashpad/crashpad/util/win/process_info.cc
index d05a23d11c2eec89bc359fccf3de4a826591d3cc..2e285b8bf29dfef20c2042e5230285d95b1aa427 100644
--- a/third_party/crashpad/crashpad/util/win/process_info.cc
+++ b/third_party/crashpad/crashpad/util/win/process_info.cc
@@ -19,9 +19,12 @@
#include <algorithm>
#include <limits>
#include <memory>
+#include <new>
#include <type_traits>
#include "base/logging.h"
+#include "base/memory/free_deleter.h"
+#include "base/process/memory.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "util/numeric/safe_assignment.h"
@@ -36,6 +39,16 @@ namespace crashpad {
namespace {
+using UniqueMallocPtr = std::unique_ptr<uint8_t[], base::FreeDeleter>;
+
+UniqueMallocPtr UncheckedAllocate(size_t size) {
+ void* raw_ptr = nullptr;
+ if (!base::UncheckedMalloc(size, &raw_ptr))
+ return UniqueMallocPtr();
+
+ return UniqueMallocPtr(new (raw_ptr) uint8_t[size]);
+}
+
NTSTATUS NtQueryInformationProcess(HANDLE process_handle,
PROCESSINFOCLASS process_information_class,
PVOID process_information,
@@ -347,14 +360,20 @@ bool ReadMemoryInfo(HANDLE process, bool is_64_bit, ProcessInfo* process_info) {
std::vector<ProcessInfo::Handle> ProcessInfo::BuildHandleVector(
HANDLE process) const {
ULONG buffer_size = 2 * 1024 * 1024;
- std::unique_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
-
// Typically if the buffer were too small, STATUS_INFO_LENGTH_MISMATCH would
// return the correct size in the final argument, but it does not for
// SystemExtendedHandleInformation, so we loop and attempt larger sizes.
NTSTATUS status;
ULONG returned_length;
+ UniqueMallocPtr buffer;
for (int tries = 0; tries < 5; ++tries) {
+ buffer.reset();
+ buffer = UncheckedAllocate(buffer_size);
+ if (!buffer) {
+ LOG(ERROR) << "UncheckedAllocate";
+ return std::vector<Handle>();
+ }
+
status = crashpad::NtQuerySystemInformation(
static_cast<SYSTEM_INFORMATION_CLASS>(SystemExtendedHandleInformation),
buffer.get(),
@@ -364,8 +383,6 @@ std::vector<ProcessInfo::Handle> ProcessInfo::BuildHandleVector(
break;
buffer_size *= 2;
- buffer.reset();
- buffer.reset(new uint8_t[buffer_size]);
}
if (!NT_SUCCESS(status)) {
« no previous file with comments | « third_party/crashpad/crashpad/util/win/process_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698