Ignore:
Timestamp:
Jun 23, 2001, 10:43:17 AM (24 years ago)
Author:
sandervl
Message:

HeapSize must return -1 for invalid pointers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/os2heap.cpp

    r5605 r6080  
    1 /* $Id: os2heap.cpp,v 1.17 2001-04-27 17:35:41 sandervl Exp $ */
     1/* $Id: os2heap.cpp,v 1.18 2001-06-23 08:43:17 sandervl Exp $ */
    22
    33/*
     
    272272DWORD OS2Heap::Size(DWORD dwFlags, PVOID lpMem)
    273273{
    274 //  dprintf(("OS2Heap::Size, %X\n", lpMem));
    275   if(lpMem == NULL)
    276     return(0);
     274 HEAPELEM *helem = (HEAPELEM *)((char *)lpMem - sizeof(HEAPELEM));
     275
     276  if(lpMem == NULL) {
     277        dprintf(("OS2Heap::Size lpMem == NULL\n"));
     278        return -1;
     279  }
     280  /* verify lpMem address */
     281  if (lpMem >= (LPVOID)ulMaxAddr || lpMem < (LPVOID)0x10000)
     282  {
     283        dprintf(("OS2Heap::Size ERROR BAD HEAP POINTER:%X\n", lpMem));
     284        return -1;
     285  }
     286
     287  if(helem->magic != MAGIC_NR_HEAP)
     288  {
     289        dprintf(("OS2Heap::Size ERROR BAD HEAP POINTER:%X\n", lpMem));
     290        return -1;
     291  }
    277292
    278293  return(_msize((char *)lpMem - sizeof(HEAPELEM)) - HEAP_OVERHEAD);
Note: See TracChangeset for help on using the changeset viewer.