Skip to content

Commit fd23ce8

Browse files
authored
Fix lookup assembly (#2495)
***NO_CI***
1 parent 463fb16 commit fd23ce8

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/CLR/Core/CLR_RT_SystemAssembliesTable.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,34 @@
44
// See LICENSE file in the project root for full license information.
55
//
66
#include <nanoCLR_Runtime.h>
7-
//#include <corlib_native.h>
8-
//#include <SPOT_native.h>
9-
//#include "nanoCLR_Interop.h"
107

11-
static const CLR_RT_NativeAssemblyData *LookUpAssemblyNativeDataByName
12-
(
8+
static const CLR_RT_NativeAssemblyData *LookUpAssemblyNativeDataByName(
139
const CLR_RT_NativeAssemblyData **pAssembliesNativeData,
14-
const char *lpszAssemblyName
15-
)
10+
const char *lpszAssemblyName)
1611
{
1712
// Just sanity check to avoid crash in strcmp if name is NULL.
18-
if ( lpszAssemblyName == NULL )
13+
if (lpszAssemblyName == NULL)
1914
{
2015
return NULL;
2116
}
2217

2318
// Loops in all entries and looks for the CLR_RT_NativeAssemblyData with name same as lpszAssemblyName
24-
for ( int i = 0; pAssembliesNativeData[ i ]; i++ )
19+
for (int i = 0; pAssembliesNativeData[i]; i++)
2520
{
26-
if ( pAssembliesNativeData[ i ] != NULL && 0 == strcmp( lpszAssemblyName, pAssembliesNativeData[ i ]->m_szAssemblyName ) )
21+
if (i < g_CLR_InteropAssembliesCount && pAssembliesNativeData[i] != NULL &&
22+
0 == strcmp(lpszAssemblyName, pAssembliesNativeData[i]->m_szAssemblyName))
2723
{
28-
return pAssembliesNativeData[ i ];
24+
return pAssembliesNativeData[i];
2925
}
3026
}
27+
3128
return NULL;
3229
}
3330

34-
35-
const CLR_RT_NativeAssemblyData *GetAssemblyNativeData( const char *lpszAssemblyName )
31+
const CLR_RT_NativeAssemblyData *GetAssemblyNativeData(const char *lpszAssemblyName)
3632
{
3733
extern const CLR_RT_NativeAssemblyData *g_CLR_InteropAssembliesNativeData[];
3834

3935
// This will return NULL if there is no registered interop assembly of that name
40-
return LookUpAssemblyNativeDataByName(
41-
g_CLR_InteropAssembliesNativeData,
42-
lpszAssemblyName
43-
);
36+
return LookUpAssemblyNativeDataByName(g_CLR_InteropAssembliesNativeData, lpszAssemblyName);
4437
}
45-

0 commit comments

Comments
 (0)