Changeset 963 for trunk/dll/wrappers.c


Ignore:
Timestamp:
Feb 18, 2008, 7:33:29 PM (18 years ago)
Author:
Gregg Young
Message:

Check if pointer passed to xrealloc & xfree point to NullStr (ticket 212).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/wrappers.c

    r932 r963  
    323323VOID xfree(PVOID pv)
    324324{
    325   if (pv)
     325  if (pv && pv != NullStr)
    326326    free(pv);
    327327}
     
    357357PVOID xrealloc(PVOID pvIn, size_t cBytes, PCSZ pszSrcFile, UINT uiLineNumber)
    358358{
    359   PVOID pv = realloc(pvIn, cBytes);
    360 
    361   if (!pv && cBytes)
    362     Runtime_Error(pszSrcFile, uiLineNumber, GetPString(IDS_OUTOFMEMORY));
    363 
    364   return pv;
    365 
     359  if (pvIn != NullStr) {
     360    PVOID pv = realloc(pvIn, cBytes);
     361
     362    if (!pv && cBytes)
     363      Runtime_Error(pszSrcFile, uiLineNumber, GetPString(IDS_OUTOFMEMORY));
     364
     365    return pv;
     366  }
     367  else
     368    return xmalloc(cBytes, pszSrcFile, uiLineNumber);
    366369}
    367370
Note: See TracChangeset for help on using the changeset viewer.