Changeset 959


Ignore:
Timestamp:
Feb 18, 2008, 1:47:31 AM (18 years ago)
Author:
Gregg Young
Message:

Use xfree where appropriate. Check that buffer exists following all xmallocs. Stopped at eas.c with xfree checking. One remaining xmalloc without test in dirsize.c

Location:
trunk/dll
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/arccnrs.c

    r953 r959  
    13351335        }
    13361336      }
    1337       if (mp2)
    1338         free((CHAR *) mp2);
     1337      xfree((CHAR *) mp2);
    13391338      PostMsg(pdt->hwndClient, DM_RENDERCOMPLETE, MPFROMP(pdt),
    13401339              MPFROM2SHORT(usRes, 0));
  • trunk/dll/assoc.c

    r927 r959  
    117117  while (info) {
    118118    next = info->next;
    119     free(info->mask);
    120     free(info->cl);
    121     if (info->sig)
    122       free(info->sig);
    123     free(info);
     119    xfree(info->mask);
     120    xfree(info->cl);
     121    xfree(info->sig);
     122    xfree(info);
    124123    info = next;
    125124  }
     
    177176        info->flags = atol(flags);
    178177        if (!info->cl || !info->mask) {
    179           if (info->cl)
    180             free(info->cl);
    181           if (info->mask)
    182             free(info->mask);
    183           free(info);
     178          xfree(info->cl);
     179          xfree(info->mask);
     180          xfree(info);
    184181          break;
    185182        }
     
    272269          info->flags = addme->flags;
    273270        if (!info->cl || !info->mask) {
    274           if (info->cl)
    275             free(info->cl);
    276           if (info->mask)
    277             free(info->mask);
    278           free(info);
     271          xfree(info->cl);
     272          xfree(info->mask);
     273          xfree(info);
    279274        }
    280275        else {
     
    320315            asstail = info->prev;
    321316        }
    322         free(info->cl);
    323         free(info->mask);
    324         if (info->sig)
    325           free(info->sig);
    326         free(info);
     317        xfree(info->cl);
     318        xfree(info->mask);
     319        xfree(info->sig);
     320        xfree(info);
    327321        return TRUE;
    328322      }
     
    646640        }
    647641        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     642        if (!pszWorkBuf)
     643          break; //already complained
    648644        memset(&temp, 0, sizeof(ASSOC));
    649645        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
     
    735731
    736732        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     733        if (!pszWorkBuf)
     734          break; //already complained
    737735        memset(&temp, 0, sizeof(ASSOC));
    738736        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
     
    850848                                      MPFROMSHORT(LIT_CURSOR), MPVOID);
    851849        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     850        if (!pszWorkBuf)
     851          break; //already complained
    852852        memset(&temp, 0, sizeof(ASSOC));
    853853        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
  • trunk/dll/autoview.c

    r907 r959  
    892892    stopflag++;
    893893    if (!PostMsg(hwndAutoObj, msg, mp1, mp2)) {
    894       if (mp1)
    895         free((CHAR *) mp1);
     894      xfree((CHAR *) mp1);
    896895    }
    897896    return 0;
  • trunk/dll/avv.c

    r931 r959  
    100100    PSZ pszWorkBuf;
    101101    pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    102     NormalizeCmdLine(pszWorkBuf, szCmdLine);
    103     pszDest = xstrdup(szCmdLine, pszSrcFile, __LINE__);
    104     xfree(pszWorkBuf);
     102    if (pszWorkBuf) {
     103      NormalizeCmdLine(pszWorkBuf, szCmdLine);
     104      pszDest = xstrdup(pszWorkBuf, pszSrcFile, __LINE__);
     105      xfree(pszWorkBuf);
     106    }
     107    else
     108      pszDest = xstrdup(szCmdLine, pszSrcFile, __LINE__); // return the unexamined input on failure
    105109  }
    106110  else
  • trunk/dll/command.c

    r927 r959  
    305305  while (info) {
    306306    next = info->next;
    307     free(info->title);
    308     free(info->cl);
     307    xfree(info->title);
     308    xfree(info->cl);
    309309    free(info);
    310310    info = next;
     
    353353        info->flags = atol(flags);
    354354        if (!info->cl || !info->title) {
    355           if (info->cl)
    356             free(info->cl);
    357           if (info->title)
    358             free(info->title);
     355          xfree(info->cl);
     356          xfree(info->title);
    359357          free(info);
    360358          break;
     
    459457            cmdtail = info->prev;
    460458        }
    461         free(info->cl);
    462         free(info->title);
     459        xfree(info->cl);
     460        xfree(info->title);
    463461        free(info);
    464462        return TRUE;
     
    625623
    626624        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     625        if (!pszWorkBuf)
     626          break; //already complained
    627627        memset(&temp, 0, sizeof(COMMAND));
    628628        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
     
    721721
    722722        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     723        if (!pszWorkBuf)
     724          break; //already complained
    723725        memset(&temp, 0, sizeof(COMMAND));
    724726        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
     
    823825
    824826        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     827        if (!pszWorkBuf)
     828          break; //already complained
    825829        memset(&temp, 0, sizeof(COMMAND));
    826830        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
  • trunk/dll/common.c

    r948 r959  
    586586        if (!PostMsg((fComments) ? hwndAutoMLE : hwndAutoview,
    587587                     UM_LOADFILE, MPFROMP(s), MPVOID)) {
    588           if (s)
    589             free(s);
     588          xfree(s);
    590589        }
    591590      }
  • trunk/dll/comp.c

    r938 r959  
    102102    if (mask) {
    103103      BldFullPathName(mask, path, "*");
    104       // sprintf(mask,
    105       //         "%s%s*",
    106       //         path, (path[strlen(path) - 1] != '\\') ? "\\" : NullStr);
    107104      enddir = strrchr(mask, '\\');
    108105      enddir++;
  • trunk/dll/copyf.c

    r907 r959  
    783783  }
    784784
    785   free(f);
    786   free(ss);
     785  xfree(f);
     786  xfree(ss);
    787787  free(str);
    788788  return 0;
     
    856856  }
    857857
    858   free(f);
    859   free(ss);
     858  xfree(f);
     859  xfree(ss);
    860860  free(str);
    861861  return 0;
  • trunk/dll/datamin.c

    r907 r959  
    6666    {
    6767      PVOID pv = xmalloc(sizeof(tDataMin), pszSrcFile, __LINE__);
    68 
    69       WinSetWindowPtr(hwnd, QWL_DATAMIN_PTR, pv);
     68      if (pv)
     69        WinSetWindowPtr(hwnd, QWL_DATAMIN_PTR, pv);
    7070    }
    7171    break;
  • trunk/dll/dirsize.c

    r920 r959  
    147147   * requesting EASIZE.  sheesh.
    148148   */
    149   if (((!rc || rc == ERROR_NO_MORE_FILES) && (pffbArray->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) {
     149  if (((!rc || rc == ERROR_NO_MORE_FILES) && (pffbArray->attrFile & FILE_DIRECTORY)) ||
     150      strlen(pszFileName) < 4) {
    150151    if (*pchStopFlag) {
    151152      free(pffbArray);
  • trunk/dll/draglist.c

    r907 r959  
    722722      _heap_check();
    723723#endif
    724       free(ppDItem);
     724      xfree(ppDItem);
    725725      ppDItem = NULL;                   // Remember gone
    726726      DosPostEventSem(CompactSem);
     
    746746    }
    747747  }
    748   if (ppDItem)
    749     free(ppDItem);
    750   if (paDImgIcons)
    751     free(paDImgIcons);
     748  xfree(ppDItem);
     749  xfree(paDImgIcons);
    752750  return hDrop;
    753751}
  • trunk/dll/literal.c

    r907 r959  
    9494  cBufBytes = strlen(pszBuf) + 1;
    9595  pszWork = pszOut = xmalloc(cBufBytes + 1, pszSrcFile, __LINE__);
     96  if (!pszWork)
     97    return 0;
    9698
    9799  iBuf = 0;                                /* set index to first character */
  • trunk/dll/misc.c

    r945 r959  
    734734              pci->pszSubject = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__);
    735735          }
    736           else
     736          else {
    737737            pci->pszSubject = xmalloc(retlen + 1, pszSrcFile, __LINE__);
     738            if (!pci->pszSubject)
     739              return FALSE;
     740          }
    738741          len = strlen(szSubject);
    739742          if (len)
  • trunk/dll/notebook.c

    r953 r959  
    203203
    204204      pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     205      if (!pszWorkBuf)
     206        return 0; //already complained
    205207      WinQueryDlgItemText(hwnd, CFGA_VIRUS, MAXCOMLINESTRG, szCLBuf);
    206208      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     
    468470
    469471      pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     472      if (!pszWorkBuf)
     473        return 0; //already complained
    470474      WinQueryDlgItemText(hwnd, CFGV_VIEWER, MAXCOMLINESTRG, szCLBuf);
    471475      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     
    657661
    658662  case WM_CLOSE:
    659     { // fixme these strings can be longer than CCHMAXPATH since
    660       // they contain args.
     663    {
    661664      CHAR szCLBuf[MAXCOMLINESTRG], szPathBuf[CCHMAXPATH];
    662665      PSZ pszWorkBuf;
    663666
    664667      pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     668      if (!pszWorkBuf)
     669        return 0; //already complained
    665670      WinQueryDlgItemText(hwnd, CFGH_RUNHTTPWORKDIR, CCHMAXPATH, szPathBuf);
    666671      szPathBuf[CCHMAXPATH - 1] = 0;
     
    12751280
    12761281      pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     1282      if (!pszWorkBuf)
     1283        return 0; //already complained
    12771284      WinQueryDlgItemText(hwnd, CFGC_DIRCOMPARE, MAXCOMLINESTRG, szCLBuf);
    12781285        szCLBuf[MAXCOMLINESTRG - 1] = 0;
Note: See TracChangeset for help on using the changeset viewer.