fixed some missing NULL checks, reported by M Bealby in bug #1110
[reactos.git] / reactos / lib / kernel32 / misc / atom.c
index 6643c9f..7a4a916 100644 (file)
@@ -238,6 +238,11 @@ GlobalGetAtomNameA(ATOM nAtom,
    Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
                            HEAP_ZERO_MEMORY,
                            BufferSize);
+   if (Buffer == NULL)
+   {
+       SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+       return 0;
+   }
 
    Status = NtQueryInformationAtom(nAtom,
                                   AtomBasicInformation,
@@ -249,6 +254,7 @@ GlobalGetAtomNameA(ATOM nAtom,
        RtlFreeHeap(RtlGetProcessHeap(),
                    0,
                    Buffer);
+        SetLastErrorByStatus(Status);
        return 0;
      }
 
@@ -287,6 +293,11 @@ GlobalGetAtomNameW(ATOM nAtom,
    Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
                            HEAP_ZERO_MEMORY,
                            BufferSize);
+   if (Buffer == NULL)
+   {
+       SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+       return 0;
+   }
 
    Status = NtQueryInformationAtom(nAtom,
                                   AtomBasicInformation,
@@ -298,6 +309,7 @@ GlobalGetAtomNameW(ATOM nAtom,
        RtlFreeHeap(RtlGetProcessHeap(),
                    0,
                    Buffer);
+        SetLastErrorByStatus(Status);
        return 0;
      }
 
@@ -552,6 +564,11 @@ GetAtomNameA(ATOM nAtom,
    Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
                            HEAP_ZERO_MEMORY,
                            NameLength);
+   if (Buffer == NULL)
+   {
+       SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+       return 0;
+   }
 
    Status = RtlQueryAtomInAtomTable(AtomTable,
                                    nAtom,
@@ -564,6 +581,7 @@ GetAtomNameA(ATOM nAtom,
        RtlFreeHeap(RtlGetProcessHeap(),
                    0,
                    Buffer);
+        SetLastErrorByStatus(Status);
        return 0;
      }