diff --git a/src/api/burn/balutil/msg.cpp b/src/api/burn/balutil/msg.cpp index bf2157813..e0eb03d2b 100644 --- a/src/api/burn/balutil/msg.cpp +++ b/src/api/burn/balutil/msg.cpp @@ -504,13 +504,16 @@ static HRESULT OnCacheAcquireResolving( hr = BuffReaderReadNumber(pReader, &cSearchPaths); ExitOnFailure(hr, "Failed to read overall percentage of OnCacheAcquireResolving args."); - rgsczSearchPaths = static_cast(MemAlloc(sizeof(LPWSTR) * cSearchPaths, TRUE)); - ExitOnNull(rgsczSearchPaths, hr, E_OUTOFMEMORY, "Failed to allocate memory for search paths."); - - for (DWORD i = 0; i < cSearchPaths; ++i) + if (cSearchPaths) { - hr = BuffReaderReadString(pReader, &rgsczSearchPaths[i]); - ExitOnFailure(hr, "Failed to read search path[%u] of OnCacheAcquireResolving args.", i); + rgsczSearchPaths = static_cast(MemAlloc(sizeof(LPWSTR) * cSearchPaths, TRUE)); + ExitOnNull(rgsczSearchPaths, hr, E_OUTOFMEMORY, "Failed to allocate memory for search paths of OnCacheAcquireResolving args."); + + for (DWORD i = 0; i < cSearchPaths; ++i) + { + hr = BuffReaderReadString(pReader, &rgsczSearchPaths[i]); + ExitOnFailure(hr, "Failed to read search path[%u] of OnCacheAcquireResolving args.", i); + } } args.cSearchPaths = cSearchPaths; @@ -943,6 +946,9 @@ static HRESULT OnCachePackageComplete( hr = BuffReaderReadNumber(pReader, &results.cbSize); ExitOnFailure(hr, "Failed to read size of OnCachePackageComplete results."); + hr = BuffReaderReadNumber(pReader, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnCachePackageComplete results."); + // Callback. hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, &args, &results); @@ -2669,13 +2675,16 @@ static HRESULT OnError( hr = BuffReaderReadNumber(pReader, &cData); ExitOnFailure(hr, "Failed to read count of data of OnError args."); - rgsczData = static_cast(MemAlloc(sizeof(LPWSTR) * cData, TRUE)); - ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for search paths."); - - for (DWORD i = 0; i < cData; ++i) + if (cData) { - hr = BuffReaderReadString(pReader, &rgsczData[i]); - ExitOnFailure(hr, "Failed to read search path[%u] of OnCacheAcquireResolving args.", i); + rgsczData = static_cast(MemAlloc(sizeof(LPWSTR) * cData, TRUE)); + ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for data of OnError args."); + + for (DWORD i = 0; i < cData; ++i) + { + hr = BuffReaderReadString(pReader, &rgsczData[i]); + ExitOnFailure(hr, "Failed to read search path[%u] of OnError args.", i); + } } args.cData = cData; @@ -2839,13 +2848,16 @@ static HRESULT OnExecuteFilesInUse( hr = BuffReaderReadNumber(pReader, &cFiles); ExitOnFailure(hr, "Failed to read count of files of OnExecuteFilesInUse args."); - rgsczFiles = static_cast(MemAlloc(sizeof(LPWSTR) * cFiles, TRUE)); - ExitOnNull(rgsczFiles, hr, E_OUTOFMEMORY, "Failed to allocate memory for files in OnExecuteFilesInUse."); - - for (DWORD i = 0; i < cFiles; ++i) + if (cFiles) { - hr = BuffReaderReadString(pReader, &rgsczFiles[i]); - ExitOnFailure(hr, "Failed to read file[%u] of OnExecuteFilesInUse args.", i); + rgsczFiles = static_cast(MemAlloc(sizeof(LPWSTR) * cFiles, TRUE)); + ExitOnNull(rgsczFiles, hr, E_OUTOFMEMORY, "Failed to allocate memory for files of OnExecuteFilesInUse args."); + + for (DWORD i = 0; i < cFiles; ++i) + { + hr = BuffReaderReadString(pReader, &rgsczFiles[i]); + ExitOnFailure(hr, "Failed to read file[%u] of OnExecuteFilesInUse args.", i); + } } args.cFiles = cFiles; @@ -2933,13 +2945,16 @@ static HRESULT OnExecuteMsiMessage( hr = BuffReaderReadNumber(pReader, &cData); ExitOnFailure(hr, "Failed to read count of files of OnExecuteMsiMessage args."); - rgsczData = static_cast(MemAlloc(sizeof(LPWSTR) * cData, TRUE)); - ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for files in OnExecuteMsiMessage."); - - for (DWORD i = 0; i < cData; ++i) + if (cData) { - hr = BuffReaderReadString(pReader, &rgsczData[i]); - ExitOnFailure(hr, "Failed to read data[%u] of OnExecuteMsiMessage args.", i); + rgsczData = static_cast(MemAlloc(sizeof(LPWSTR) * cData, TRUE)); + ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for data of OnExecuteMsiMessage args."); + + for (DWORD i = 0; i < cData; ++i) + { + hr = BuffReaderReadString(pReader, &rgsczData[i]); + ExitOnFailure(hr, "Failed to read data[%u] of OnExecuteMsiMessage args.", i); + } } args.cData = cData; diff --git a/src/burn/engine/bacallback.cpp b/src/burn/engine/bacallback.cpp index 679cc5acf..45a29ac90 100644 --- a/src/burn/engine/bacallback.cpp +++ b/src/burn/engine/bacallback.cpp @@ -1193,6 +1193,9 @@ EXTERN_C HRESULT BACallbackOnCachePackageComplete( hr = BuffWriteNumberToBuffer(&buffer, results.cbSize); ExitOnFailure(hr, "Failed to write size of OnCachePackageComplete results."); + hr = BuffWriteNumberToBuffer(&buffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnCachePackageComplete results."); + hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize); ExitOnFailure(hr, "Failed to add padding to OnCachePackageComplete results.");