Skip to content

Commit

Permalink
Fix GetInteropNativeAssemblies (#1556)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Feb 18, 2020
1 parent a904948 commit 7e6c44f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/CLR/Debugger/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,11 +1141,15 @@ static bool GetInteropNativeAssemblies( uint8_t* &data, int* size, uint32_t star
// - if 0, adjust to the assemblies count to make the execution backwards compatible
// - trim if over the available assembly count
// (max possible page size is 255)
if( count == 0 ||
count > 255 ||
(count + startIndex) > nativeAssembliesCount)
if(startIndex == 0 && count == 0)
{
// adjust to the assemblies count to make the execution backwards compatible
count = nativeAssembliesCount;
}
else if(count > 255 ||
count + startIndex > nativeAssembliesCount)
{
// adjust to the assemblies count so it doesn't overflow
count = nativeAssembliesCount - startIndex;
}

Expand All @@ -1158,7 +1162,7 @@ static bool GetInteropNativeAssemblies( uint8_t* &data, int* size, uint32_t star
return false;
}

// clear memory
// clear buffer memory
memset(
interopNativeAssemblies,
0,
Expand All @@ -1172,7 +1176,7 @@ static bool GetInteropNativeAssemblies( uint8_t* &data, int* size, uint32_t star
// we have an assembly at this position
// check if it's on the requested range
if( i >= startIndex &&
i <= (startIndex + count))
i < (startIndex + count))
{
interopNativeAssemblies[index].CheckSum = g_CLR_InteropAssembliesNativeData[i]->m_checkSum;
hal_strcpy_s((char*)interopNativeAssemblies[index].AssemblyName, ARRAYSIZE(interopNativeAssemblies[index].AssemblyName), g_CLR_InteropAssembliesNativeData[i]->m_szAssemblyName);
Expand All @@ -1187,8 +1191,10 @@ static bool GetInteropNativeAssemblies( uint8_t* &data, int* size, uint32_t star
}
}

// copy back the buffer
data = (uint8_t*)interopNativeAssemblies;

// set buffer size
*size = (sizeof(CLR_DBG_Commands::Debugging_Execution_QueryCLRCapabilities::NativeAssemblyDetails) * count);

return true;
Expand Down

0 comments on commit 7e6c44f

Please sign in to comment.