Bug 1454448 - Properly handle an allocation failure. r=rstrong
authorMatt Howell <mhowell@mozilla.com>
Thu, 19 Apr 2018 14:14:53 -0700
changeset 468385 983b15929e0424b2346df3d39af2d352ed4db0b9
parent 468384 c5f309cfe1cb9a07b09235b16f44312c40c97e6e
child 468386 b876ed208711bc346d7ca95b0599f6e4eb02ff2e
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs1454448
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1454448 - Properly handle an allocation failure. r=rstrong
toolkit/components/maintenanceservice/workmonitor.cpp
--- a/toolkit/components/maintenanceservice/workmonitor.cpp
+++ b/toolkit/components/maintenanceservice/workmonitor.cpp
@@ -572,25 +572,29 @@ ExecuteServiceCommand(int argc, LPWSTR *
 {
   if (argc < 3) {
     LOG_WARN(("Not enough command line arguments to execute a service command"));
     return FALSE;
   }
 
   // The tests work by making sure the log has changed, so we put a
   // unique ID in the log.
-  RPC_WSTR guidString = RPC_WSTR(L"");
   GUID guid;
   HRESULT hr = CoCreateGuid(&guid);
   if (SUCCEEDED(hr)) {
-    UuidToString(&guid, &guidString);
+    RPC_WSTR guidString = RPC_WSTR(L"");
+    if (UuidToString(&guid, &guidString) == RPC_S_OK) {
+      LOG(("Executing service command %ls, ID: %ls",
+           argv[2], reinterpret_cast<LPCWSTR>(guidString)));
+      RpcStringFree(&guidString);
+    } else {
+      // The ID is only used by tests, so failure to allocate it isn't fatal.
+      LOG(("Executing service command %ls", argv[2]));
+    }
   }
-  LOG(("Executing service command %ls, ID: %ls",
-       argv[2], reinterpret_cast<LPCWSTR>(guidString)));
-  RpcStringFree(&guidString);
 
   BOOL result = FALSE;
   if (!lstrcmpi(argv[2], L"software-update")) {
     // This check is also performed in updater.cpp and is performed here
     // as well since the maintenance service can be called directly.
     if (argc < 4 || !IsValidFullPath(argv[4])) {
       // Since the status file is written to the patch directory and the patch
       // directory is invalid don't write the status file.