[RTL] Handle RtlReAllocateHeap failure in com_class_add_progid. CID 1223161
[reactos.git] / sdk / lib / rtl / actctx.c
index e2e74ad..6ce1734 100644 (file)
@@ -1504,8 +1504,11 @@ static BOOL com_class_add_progid(const xmlstr_t *progid, struct entity *entity)
 
     if (progids->allocated == progids->num)
     {
+        WCHAR **new_progids = RtlReAllocateHeap(RtlGetProcessHeap(), 0, progids->progids,
+                                                2 * progids->allocated * sizeof(WCHAR*));
+        if (!new_progids) return FALSE;
         progids->allocated *= 2;
-        progids->progids = RtlReAllocateHeap(RtlGetProcessHeap(), 0, progids->progids, progids->allocated * sizeof(WCHAR*));
+        progids->progids = new_progids;
     }
 
     if (!(progids->progids[progids->num] = xmlstrdupW(progid))) return FALSE;
@@ -2515,7 +2518,7 @@ static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_ident
                                                       : ACTIVATION_CONTEXT_PATH_TYPE_NONE;
 
     unicode_tests = IS_TEXT_UNICODE_SIGNATURE | IS_TEXT_UNICODE_REVERSE_SIGNATURE;
-    if (RtlIsTextUnicode((PVOID)buffer, (ULONG)size, &unicode_tests ))
+    if (RtlIsTextUnicode(buffer, size, &unicode_tests ))
     {
         xmlbuf.ptr = buffer;
         xmlbuf.end = xmlbuf.ptr + size / sizeof(WCHAR);
@@ -2579,11 +2582,7 @@ static NTSTATUS open_nt_file( HANDLE *handle, UNICODE_STRING *name )
     attr.ObjectName = name;
     attr.SecurityDescriptor = NULL;
     attr.SecurityQualityOfService = NULL;
-    return NtOpenFile(handle,
-                      GENERIC_READ | SYNCHRONIZE,
-                      &attr, &io,
-                      FILE_SHARE_READ,
-                      FILE_SYNCHRONOUS_IO_ALERT);
+    return NtOpenFile( handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT );
 }
 
 static NTSTATUS get_module_filename( HMODULE module, UNICODE_STRING *str, USHORT extra_len )
@@ -2837,9 +2836,8 @@ static WCHAR *lookup_manifest_file( HANDLE dir, struct assembly_identity *ai )
               ai->version.major, ai->version.minor, lang );
     RtlInitUnicodeString( &lookup_us, lookup );
 
-    NtQueryDirectoryFile( dir, 0, NULL, NULL, &io, buffer, sizeof(buffer),
-                          FileBothDirectoryInformation, FALSE, &lookup_us, TRUE );
-    if (io.Status == STATUS_SUCCESS)
+    if (!NtQueryDirectoryFile( dir, 0, NULL, NULL, &io, buffer, sizeof(buffer),
+                               FileBothDirectoryInformation, FALSE, &lookup_us, TRUE ))
     {
         ULONG min_build = ai->version.build, min_revision = ai->version.revision;
         FILE_BOTH_DIR_INFORMATION *dir_info;
@@ -2852,9 +2850,9 @@ static WCHAR *lookup_manifest_file( HANDLE dir, struct assembly_identity *ai )
         {
             if (data_pos >= data_len)
             {
-                NtQueryDirectoryFile( dir, 0, NULL, NULL, &io, buffer, sizeof(buffer),
-                                      FileBothDirectoryInformation, FALSE, &lookup_us, FALSE );
-                if (io.Status != STATUS_SUCCESS) break;
+                if (NtQueryDirectoryFile( dir, 0, NULL, NULL, &io, buffer, sizeof(buffer),
+                                          FileBothDirectoryInformation, FALSE, &lookup_us, FALSE ))
+                    break;
                 data_len = (ULONG)io.Information;
                 data_pos = 0;
             }
@@ -2933,11 +2931,8 @@ static NTSTATUS lookup_winsxs(struct actctx_loader* acl, struct assembly_identit
     attr.SecurityDescriptor = NULL;
     attr.SecurityQualityOfService = NULL;
 
-    if (!NtOpenFile(&handle,
-                    GENERIC_READ | SYNCHRONIZE,
-                    &attr, &io,
-                    FILE_SHARE_READ | FILE_SHARE_WRITE,
-                    FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT))
+    if (!NtOpenFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE,
+                     FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT ))
     {
         sxs_ai = *ai;
         file = lookup_manifest_file( handle, &sxs_ai );
@@ -3230,7 +3225,8 @@ static struct string_index *find_string_index(const struct strsection_header *se
         {
             const WCHAR *nameW = (WCHAR*)((BYTE*)section + iter->name_offset);
 
-            if (!strcmpiW(nameW, name->Buffer))
+            if (!_wcsnicmp(nameW, name->Buffer, name->Length / sizeof(WCHAR)) && 
+                wcslen(nameW) == name->Length / sizeof(WCHAR))
             {
                 index = iter;
                 break;
@@ -4764,7 +4760,7 @@ RtlCreateActivationContext(IN ULONG Flags,
         }
 
         ret = RtlDosPathNameToNtPathName_U(source ? source : pActCtx->lpSource, &nameW, NULL, NULL);
-        if (source) RtlFreeHeap( RtlGetProcessHeap(), 0, source );
+        RtlFreeHeap( RtlGetProcessHeap(), 0, source );
         if (!ret)
         {
             status = STATUS_NO_SUCH_FILE;