diff --git a/reactos/dll/shellext/ntobjshex/ntobjenum.cpp b/reactos/dll/shellext/ntobjshex/ntobjenum.cpp index 603b1440d50..a19938156d1 100644 --- a/reactos/dll/shellext/ntobjshex/ntobjenum.cpp +++ b/reactos/dll/shellext/ntobjshex/ntobjenum.cpp @@ -227,7 +227,7 @@ public: DWORD entryBufferLength = FIELD_OFFSET(RegPidlEntry, entryName) + sizeof(WCHAR) + cchName * sizeof(WCHAR); // allocate space for the terminator - entryBufferLength += 2; + entryBufferLength += FIELD_OFFSET(SHITEMID, abID); RegPidlEntry* entry = (RegPidlEntry*) CoTaskMemAlloc(entryBufferLength); if (!entry) @@ -377,7 +377,7 @@ public: } // allocate space for the terminator - entryBufferLength += 2; + entryBufferLength += FIELD_OFFSET(SHITEMID, abID); RegPidlEntry* entry = (RegPidlEntry*) CoTaskMemAlloc(entryBufferLength); if (!entry) @@ -432,7 +432,8 @@ public: DWORD entryBufferLength = FIELD_OFFSET(RegPidlEntry, entryName) + sizeof(WCHAR) + cchName * sizeof(WCHAR); - BOOL copyData = dataSize <= 32; +#define MAX_EMBEDDED_DATA 32 + BOOL copyData = dataSize <= MAX_EMBEDDED_DATA; if (copyData) { entryBufferLength += dataSize + sizeof(WCHAR); @@ -441,7 +442,7 @@ public: } // allocate space for the terminator - entryBufferLength += 2; + entryBufferLength += FIELD_OFFSET(SHITEMID, abID); RegPidlEntry* entry = (RegPidlEntry*) CoTaskMemAlloc(entryBufferLength); if (!entry) @@ -636,7 +637,7 @@ public: } // allocate space for the terminator - entryBufferLength += 2; + entryBufferLength += FIELD_OFFSET(SHITEMID, abID); NtPidlEntry* entry = (NtPidlEntry*) CoTaskMemAlloc(entryBufferLength); if (!entry) diff --git a/reactos/dll/shellext/ntobjshex/regfolder.cpp b/reactos/dll/shellext/ntobjshex/regfolder.cpp index c9f9c1406d5..8781886b1c9 100644 --- a/reactos/dll/shellext/ntobjshex/regfolder.cpp +++ b/reactos/dll/shellext/ntobjshex/regfolder.cpp @@ -308,16 +308,16 @@ public: case REG_MULTI_SZ: { PCWSTR separator = L" "; // To match regedit - int sepChars = wcslen(separator); + size_t sepChars = wcslen(separator); int strings = 0; int stringChars = 0; PCWSTR strData = (PCWSTR)td; while (*strData) { - int l = wcslen(strData); - stringChars += l; - strData += l + 1; // Skips null-terminator + size_t len = wcslen(strData); + stringChars += len; + strData += len + 1; // Skips null-terminator strings++; } @@ -363,7 +363,7 @@ public: PWSTR strValue = (PWSTR)CoTaskMemAlloc(bufferLength); PWSTR strTemp = strValue; PBYTE data = (PBYTE)td; - for (int i = 0; i < contentsLength; i++) + for (DWORD i = 0; i < contentsLength; i++) { StringCbPrintfW(strTemp, bufferLength, L"%02x ", data[i]); strTemp += 3;