From abdbced4fdb72666507f88389621176a11cc0a7d Mon Sep 17 00:00:00 2001 From: "Dimitrie O. Paun" Date: Sat, 29 Apr 2000 14:20:28 +0000 Subject: [PATCH] Removed some HEAP_xalloc calls. --- dlls/lzexpand/lzexpand_main.c | 16 ++++++++++++---- files/dos_fs.c | 4 ++-- files/profile.c | 29 ++++++++++++++++++++--------- graphics/painting.c | 10 +++++++--- windows/x11drv/event.c | 6 ++++-- 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/dlls/lzexpand/lzexpand_main.c b/dlls/lzexpand/lzexpand_main.c index adedcfe5bee..7e99234c490 100644 --- a/dlls/lzexpand/lzexpand_main.c +++ b/dlls/lzexpand/lzexpand_main.c @@ -178,16 +178,23 @@ HFILE WINAPI LZInit( HFILE hfSrc ) for (i = 0; i < MAX_LZSTATES; i++) if (!lzstates[i]) break; if (i == MAX_LZSTATES) return LZERROR_GLOBALLOC; lzstates[i] = lzs = HeapAlloc( GetProcessHeap(), 0, sizeof(struct lzstate) ); - + if(lzs == NULL) return LZERROR_GLOBALLOC; + memset(lzs,'\0',sizeof(*lzs)); lzs->realfd = hfSrc; lzs->lastchar = head.lastchar; lzs->reallength = head.reallength; - lzs->get = HEAP_xalloc( GetProcessHeap(), 0, GETLEN ); + lzs->get = HeapAlloc( GetProcessHeap(), 0, GETLEN ); lzs->getlen = 0; lzs->getcur = 0; + if(lzs->get == NULL) { + HeapFree(GetProcessHeap(), 0, lzs); + lzstates[i] = NULL; + return LZERROR_GLOBALLOC; + } + /* Yes, preinitialize with spaces */ memset(lzs->table,' ',0x1000); /* Yes, start 16 byte from the END of the table */ @@ -534,8 +541,9 @@ LONG WINAPI LZCopy( HFILE src, HFILE dest ) static LPSTR LZEXPAND_MangleName( LPCSTR fn ) { char *p; - char *mfn = (char *)HEAP_xalloc( GetProcessHeap(), 0, - strlen(fn) + 3 ); /* "._" and \0 */ + char *mfn = (char *)HeapAlloc( GetProcessHeap(), 0, + strlen(fn) + 3 ); /* "._" and \0 */ + if(mfn == NULL) return NULL; strcpy( mfn, fn ); if (!(p = strrchr( mfn, '\\' ))) p = mfn; if ((p = strchr( p, '.' ))) diff --git a/files/dos_fs.c b/files/dos_fs.c index b2fd0fa9542..e6575854f34 100644 --- a/files/dos_fs.c +++ b/files/dos_fs.c @@ -992,7 +992,7 @@ DWORD WINAPI GetShortPathNameW( LPCWSTR longpath, LPWSTR shortpath, DWORD ret = 0; longpathA = HEAP_strdupWtoA( GetProcessHeap(), 0, longpath ); - shortpathA = HEAP_xalloc ( GetProcessHeap(), 0, shortlen ); + shortpathA = HeapAlloc ( GetProcessHeap(), 0, shortlen ); ret = GetShortPathNameA ( longpathA, shortpathA, shortlen ); lstrcpynAtoW ( shortpath, shortpathA, shortlen ); @@ -1953,7 +1953,7 @@ DWORD WINAPI QueryDosDeviceA(LPCSTR devname,LPSTR target,DWORD bufsize) DWORD WINAPI QueryDosDeviceW(LPCWSTR devname,LPWSTR target,DWORD bufsize) { LPSTR devnameA = devname?HEAP_strdupWtoA(GetProcessHeap(),0,devname):NULL; - LPSTR targetA = (LPSTR)HEAP_xalloc(GetProcessHeap(),0,bufsize); + LPSTR targetA = (LPSTR)HeapAlloc(GetProcessHeap(),0,bufsize); DWORD ret = QueryDosDeviceA(devnameA,targetA,bufsize); lstrcpynAtoW(target,targetA,bufsize); diff --git a/files/profile.c b/files/profile.c index f4fa3bba1ff..764441310c4 100644 --- a/files/profile.c +++ b/files/profile.c @@ -202,7 +202,8 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) PROFILESECTION **next_section; PROFILEKEY *key, *prev_key, **next_key; - first_section = HEAP_xalloc( GetProcessHeap(), 0, sizeof(*section) ); + first_section = HeapAlloc( GetProcessHeap(), 0, sizeof(*section) ); + if(first_section == NULL) return NULL; first_section->name = NULL; first_section->key = NULL; first_section->next = NULL; @@ -226,7 +227,8 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) { *p2 = '\0'; p++; - section = HEAP_xalloc( GetProcessHeap(), 0, sizeof(*section) ); + section = HeapAlloc( GetProcessHeap(), 0, sizeof(*section) ); + if(section == NULL) break; section->name = HEAP_strdupA( GetProcessHeap(), 0, p ); section->key = NULL; section->next = NULL; @@ -253,8 +255,9 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) } if(*p || !prev_key || *prev_key->name) - { - key = HEAP_xalloc( GetProcessHeap(), 0, sizeof(*key) ); + { + key = HeapAlloc( GetProcessHeap(), 0, sizeof(*key) ); + if(key == NULL) break; key->name = HEAP_strdupA( GetProcessHeap(), 0, p ); key->value = p2 ? HEAP_strdupA( GetProcessHeap(), 0, p2 ) : NULL; key->next = NULL; @@ -263,7 +266,7 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) prev_key = key; TRACE("New key: name='%s', value='%s'\n",key->name,key->value?key->value:"(none)"); - } + } } return first_section; } @@ -426,7 +429,8 @@ static PROFILEKEY *PROFILE_Find( PROFILESECTION **section, key = &(*key)->next; } if (!create) return NULL; - *key = HEAP_xalloc( GetProcessHeap(), 0, sizeof(PROFILEKEY) ); + *key = HeapAlloc( GetProcessHeap(), 0, sizeof(PROFILEKEY) ); + if(*key == NULL) return NULL; (*key)->name = HEAP_strdupA( GetProcessHeap(), 0, key_name ); (*key)->value = NULL; (*key)->next = NULL; @@ -435,10 +439,16 @@ static PROFILEKEY *PROFILE_Find( PROFILESECTION **section, section = &(*section)->next; } if (!create) return NULL; - *section = HEAP_xalloc( GetProcessHeap(), 0, sizeof(PROFILESECTION) ); + *section = HeapAlloc( GetProcessHeap(), 0, sizeof(PROFILESECTION) ); + if(*section == NULL) return NULL; (*section)->name = HEAP_strdupA( GetProcessHeap(), 0, section_name ); (*section)->next = NULL; - (*section)->key = HEAP_xalloc( GetProcessHeap(), 0, sizeof(PROFILEKEY) ); + (*section)->key = HeapAlloc( GetProcessHeap(), 0, sizeof(PROFILEKEY) ); + if((*section)->key == NULL) + { + HeapFree(GetProcessHeap(), 0, *section); + return NULL; + } (*section)->key->name = HEAP_strdupA( GetProcessHeap(), 0, key_name ); (*section)->key->value = NULL; (*section)->key->next = NULL; @@ -535,7 +545,8 @@ static BOOL PROFILE_Open( LPCSTR filename ) if(!CurProfile) for(i=0;ichanged=FALSE; MRUProfile[i]->section=NULL; MRUProfile[i]->dos_name=NULL; diff --git a/graphics/painting.c b/graphics/painting.c index 61404ad796b..3413c58bf39 100644 --- a/graphics/painting.c +++ b/graphics/painting.c @@ -712,11 +712,15 @@ BOOL16 WINAPI PolyPolygon16( HDC16 hdc, const POINT16* pt, const INT16* counts, nrpts=0; for (i=polygons;i--;) nrpts+=counts[i]; - pt32 = (LPPOINT)HEAP_xalloc( GetProcessHeap(), 0, sizeof(POINT)*nrpts); + pt32 = (LPPOINT)HeapAlloc( GetProcessHeap(), 0, sizeof(POINT)*nrpts); + if(pt32 == NULL) return FALSE; for (i=nrpts;i--;) CONV_POINT16TO32(&(pt[i]),&(pt32[i])); - counts32 = (LPINT)HEAP_xalloc( GetProcessHeap(), 0, - polygons*sizeof(INT) ); + counts32 = (LPINT)HeapAlloc( GetProcessHeap(), 0, polygons*sizeof(INT) ); + if(counts32 == NULL) { + HeapFree( GetProcessHeap(), 0, pt32 ); + return FALSE; + } for (i=polygons;i--;) counts32[i]=counts[i]; ret = PolyPolygon(hdc,pt32,counts32,polygons); diff --git a/windows/x11drv/event.c b/windows/x11drv/event.c index bcb8fd246ee..6ab43346e14 100644 --- a/windows/x11drv/event.c +++ b/windows/x11drv/event.c @@ -984,7 +984,8 @@ static Atom EVENT_SelectionRequest_TARGETS( Window requestor, Atom target, Atom cTargets++; /* Allocate temp buffer */ - targets = (Atom*)HEAP_xalloc( GetProcessHeap(), 0, cTargets * sizeof(Atom)); + targets = (Atom*)HeapAlloc( GetProcessHeap(), 0, cTargets * sizeof(Atom)); + if(targets == NULL) return None; /* Create TARGETS property list (First item in list is TARGETS itself) */ @@ -1080,7 +1081,8 @@ static Atom EVENT_SelectionRequest_STRING( Window requestor, Atom target, Atom r size = GlobalSize16(hText); /* remove carriage returns */ - lpstr = (char*)HEAP_xalloc( GetProcessHeap(), 0, size-- ); + lpstr = (char*)HeapAlloc( GetProcessHeap(), 0, size-- ); + if(lpstr == NULL) return None; for(i=0,j=0; i < size && text[i]; i++ ) { if( text[i] == '\r' && -- 2.11.4.GIT