Changeset 1032


Ignore:
Timestamp:
Jun 30, 2008, 4:55:36 AM (17 years ago)
Author:
Gregg Young
Message:

Fortify updates including a leave scope wrapper which frees and in some cases reloads commands, archivers, association, etc.

Location:
trunk/dll
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/arccnrs.c

    r1018 r1032  
    337337    psz = pai->pszFileName;
    338338    pai->pszFileName = NullStr;
     339# ifdef FORTIFY
     340    xfree(psz, pszSrcFile, __LINE__);
     341# else
    339342    free(psz);
     343# endif
     344# ifdef FORTIFY
     345  Fortify_LeaveScope();
     346# endif
    340347  }
    341348}
     
    18061813                      li->list[x] = temp;
    18071814                    else {
    1808                       free(temp);
     1815                      xfree(temp, pszSrcFile, __LINE__);
    18091816                    }
    18101817                  }
     
    18161823                  li->list[x] = temp;
    18171824                else
    1818                   free(temp);
     1825                  xfree(temp, pszSrcFile, __LINE__);
    18191826              }
    18201827              if (li->type == IDM_VIEW || li->type == IDM_EDIT) {
  • trunk/dll/autoview.c

    r1029 r1032  
    668668      }
    669669      else {
     670# ifdef FORTIFY
     671  Fortify_EnterScope();
     672# endif
    670673        WinSetWindowULong(hwndAutoObj, QWL_USER, hwndParent);
    671674        priority_normal();
     
    677680      WinDestroyMsgQueue(hmq2);
    678681    }
    679     else
    680       WinTerminate(hab2);
     682    // else
     683    WinTerminate(hab2);
     684# ifdef FORTIFY
     685    xFortify_LeaveScope(pszSrcFile, __LINE__);
     686# endif
    681687  }
    682688}
  • trunk/dll/comp.c

    r1029 r1032  
    203203      hmq2 = WinCreateMsgQueue(hab2, 0);
    204204      if (hmq2) {
     205# ifdef FORTIFY
     206  Fortify_EnterScope();
     207# endif
    205208        WinCancelShutdown(hmq2, TRUE);
    206209        IncrThreadUsage();
     
    312315      }
    313316      WinTerminate(hab2);
     317# ifdef FORTIFY
     318      xFortify_LeaveScope(pszSrcFile, __LINE__);
     319# endif
    314320    }
    315321  }
     
    404410    hmq = WinCreateMsgQueue(hab, 0);
    405411    if (hmq) {
     412# ifdef FORTIFY
     413  Fortify_EnterScope();
     414# endif
    406415      WinCancelShutdown(hmq, TRUE);
    407416      IncrThreadUsage();
     
    682691    // PostMsg(cmp->hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DESELECTALL, 0), MPVOID);        // 18 Jan 08 SHL we can count now
    683692    DecrThreadUsage();
     693    xfree(cmp, pszSrcFile, __LINE__);
    684694    WinTerminate(hab);
     695# ifdef FORTIFY
     696    xFortify_LeaveScope(pszSrcFile, __LINE__);
     697# endif
    685698  }
    686   xfree(cmp, pszSrcFile, __LINE__);
     699  else
     700    xfree(cmp, pszSrcFile, __LINE__);
    687701}
    688702
     
    708722    hmq = WinCreateMsgQueue(hab, 0);
    709723    if (hmq) {
     724# ifdef FORTIFY
     725  Fortify_EnterScope();
     726# endif
    710727      WinCancelShutdown(hmq, TRUE);
    711728      IncrThreadUsage();
     
    739756    }
    740757    DecrThreadUsage();
     758    xfree(cmp, pszSrcFile, __LINE__);
    741759    WinTerminate(hab);
     760# ifdef FORTIFY
     761    xFortify_LeaveScope(pszSrcFile, __LINE__);
     762# endif
    742763  }
    743   xfree(cmp, pszSrcFile, __LINE__);
     764  else
     765    xfree(cmp, pszSrcFile, __LINE__);
    744766}
    745767
     
    19321954          } // if on both sides
    19331955
    1934           if (x <= 0)
     1956          if (x <= 0) {
     1957# ifdef FORTIFY
     1958            xfree(filesl[l++], pszSrcFile, __LINE__);
     1959# else
    19351960            free(filesl[l++]);          // Done with item on left
    1936 
    1937           if (x >= 0)
    1938             free(filesr[r++]);          // Done with item on right
    1939 
     1961# endif
     1962          }
     1963          if (x >= 0) {
     1964# ifdef FORTIFY
     1965            xfree(filesr[r++], pszSrcFile, __LINE__);
     1966# else
     1967            free(filesr[r++]);          // Done with item on right
     1968#endif
     1969          }
    19401970          // Ensure empty buffers point somewhere
    19411971          if (!pcil->pszFileName) {
     
    19561986
    19571987          if (!pcil->pszSubject)
    1958             pcil->pszSubject = NullStr;
    19591988          if (!pcir->pszSubject)
    19601989            pcir->pszSubject = NullStr;
     
    19872016          }
    19882017          if (filesl) {
    1989             for(; filesl[l]; l++)
    1990               free(filesl[l]);
     2018            for(; filesl[l]; l++) {
     2019# ifdef FORTIFY
     2020              xfree(filesl[l], pszSrcFile, __LINE__);
     2021# else
     2022              free(filesl[l]);
     2023# endif
     2024            }
    19912025          }
    19922026          if (pcir) {
     
    19982032          }
    19992033          if (filesr) {
    2000             for (; filesr[r]; r++)
    2001               free(filesr[r]);
     2034            for (; filesr[r]; r++) {
     2035# ifdef FORTIFY
     2036              xfree(filesr[r], pszSrcFile, __LINE__);
     2037# else
     2038              free(filesr[r]);
     2039# endif
     2040            }
    20022041          }
    20032042          // Reduce count to match what is in containers
     
    20782117
    20792118# ifdef FORTIFY
    2080   // 10 May 08 SHL fixme to suppress W111
    2081   Fortify_LeaveScope();
     2119  xFortify_LeaveScope(pszSrcFile, __LINE__);
    20822120# endif
    20832121
  • trunk/dll/dircnrs.c

    r1029 r1032  
    33613361      xfree(dcd, pszSrcFile, __LINE__);
    33623362# ifdef FORTIFY
    3363   free_commands();
    3364   free_associations();
    3365   free_udir();
    3366   free_ldir();
    3367   free_archivers();
    3368   Fortify_LeaveScope();
     3363      xFortify_LeaveScope(pszSrcFile, __LINE__);
    33693364# endif
    33703365      WinSetWindowPtr(hwnd, QWL_USER, NULL);
  • trunk/dll/draglist.c

    r1011 r1032  
    714714                   "DrgSetDragitem");
    715715        }
    716         free(ppDItem[ulSelect]);
     716        xfree(ppDItem[ulSelect], pszSrcFile, __LINE__);
    717717      } // for
    718718#ifdef __DEBUG_ALLOC__
  • trunk/dll/filldir.c

    r1018 r1032  
    15851585    psz = pci->pszSubject;
    15861586    pci->pszSubject = NullStr;
     1587# ifdef FORTIFY
     1588    xfree(psz, pszSrcFile, __LINE__);
     1589# else
    15871590    free(psz);
     1591# endif
    15881592  }
    15891593
     
    15961600    psz = pci->pszLongName;
    15971601    pci->pszLongName = NullStr;
     1602# ifdef FORTIFY
     1603    xfree(psz, pszSrcFile, __LINE__);
     1604# else
    15981605    free(psz);
     1606# endif
    15991607  }
    16001608
     
    16021610    psz = pci->pszFileName;
    16031611    pci->pszFileName = NullStr;
     1612# ifdef FORTIFY
     1613    xfree(psz, pszSrcFile, __LINE__);
     1614# else
    16041615    free(psz);
     1616# endif
    16051617  }
    16061618
     
    16081620    psz = pci->pszFmtFileSize;
    16091621    pci->pszFmtFileSize = NullStr;
     1622# ifdef FORTIFY
     1623    xfree(psz, pszSrcFile, __LINE__);
     1624# else
    16101625    free(psz);
     1626# endif
    16111627  }
    16121628}
  • trunk/dll/fm3dll.h

    r1029 r1032  
    10851085PVOID xrealloc(PVOID pvIn, size_t cBytes, PCSZ pszSrcFile, UINT uiLineNumber);
    10861086PVOID xstrdup(PCSZ pszIn, PCSZ pszSrcFile, UINT uiLineNumber);
     1087unsigned char xFortify_LeaveScope(PCSZ pszSrcFile, UINT uiLineNumber);
    10871088
    10881089//=====================================================================
  • trunk/dll/grep.c

    r1029 r1032  
    411411  if (grep.dupehead)
    412412    FreeDupes(&grep);
    413   if (grep.numlines && grep.matched)
     413  if (grep.numlines && grep.matched) {
     414# ifdef FORTIFY
     415    xfree(grep.matched, pszSrcFile, __LINE__);
     416# else
    414417    free(grep.matched);
     418# endif
     419  }
    415420  // 07 Feb 08 SHL fixme to free grep here when not static
    416421# ifdef FORTIFY
     
    657662  if (grep) {
    658663    if (grep->insertffb) {
    659       for (x = 0; grep->insertffb[x]; x++)
    660         free(grep->insertffb[x]);
    661       free(grep->insertffb);
     664      for (x = 0; grep->insertffb[x]; x++) {
     665# ifdef FORTIFY
     666        xfree(grep->insertffb[x], pszSrcFile, __LINE__);
     667# else
     668        free(grep->insertffb[x]);
     669#endif
     670      }
     671      xfree(grep->insertffb, pszSrcFile, __LINE__);
    662672    }
    663673    if (grep->dir) {
    664       for (x = 0; grep->dir[x]; x++)
    665         free(grep->dir[x]);
    666       free(grep->dir);
     674      for (x = 0; grep->dir[x]; x++) {
     675# ifdef FORTIFY
     676        xfree(grep->dir[x], pszSrcFile, __LINE__);
     677# else
     678        free(grep->dir[x]);
     679# endif
     680      }
     681      xfree(grep->dir, pszSrcFile, __LINE__);
    667682    }
    668683    grep->dir = NULL;
     
    11471162  while (i) {
    11481163    next = i->next;
    1149     if (i->name)
     1164    if (i->name) {
     1165# ifdef FORTIFY
     1166      xfree(i->name, pszSrcFile, __LINE__);
     1167# else
    11501168      free(i->name);
     1169# endif
     1170    }
     1171# ifdef FORTIFY
     1172    xfree(i, pszSrcFile, __LINE__);
     1173# else
    11511174    free(i);
     1175# endif
    11521176    i = next;
    11531177  }
  • trunk/dll/mainwnd.c

    r1031 r1032  
    63646364      WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
    63656365# ifdef FORTIFY
    6366   free_commands();
    6367   free_associations();
    6368   free_udir();
    6369   free_ldir();
    6370   free_archivers();
    6371   Fortify_LeaveScope();
     6366  Fortify_LeaveScope( pszSrcFile, __LINE__);
    63726367# endif
    63736368    break;
  • trunk/dll/makelist.c

    r1029 r1032  
    9191      _heap_check();
    9292#endif
     93# ifdef FORTIFY
     94      xfree(list[x], pszSrcFile, __LINE__);
     95# else
    9396      free(list[x]);
     97# endif
    9498    }
    9599#ifdef __DEBUG_ALLOC__
     
    266270    for (x = 0; list[x]; x++) {
    267271      if (item == list[x]) {
    268         free(list[x]);
     272# ifdef FORTIFY
     273        xfree(list[x], pszSrcFile, __LINE__);
     274# else
     275        free(list[x]);
     276# endif
    269277        list[x] = NULL;
    270278        for (y = x;; y++) {
  • trunk/dll/newview.c

    r1029 r1032  
    650650    DosPostEventSem(CompactSem);
    651651# ifdef FORTIFY
    652   Fortify_LeaveScope();
     652    xFortify_LeaveScope(pszSrcFile, __LINE__);
    653653# endif
    654654  }
  • trunk/dll/objwin.c

    r907 r1032  
    2525#include "errutil.h"                    // Win_Error
    2626#include "fm3dll.h"
     27#include "fortify.h"
    2728
    2829static PSZ pszSrcFile = __FILE__;
     
    7576                   IDS_WINCREATEWINDOW);
    7677      else {
     78# ifdef FORTIFY
     79  Fortify_EnterScope();
     80# endif
    7781        WinSetWindowPtr(ObjectHwnd, QWL_USER, args);
    7882        /* initially populate container */
     
    8690      WinDestroyMsgQueue(hmq2);
    8791    }
     92# ifdef FORTIFY
     93    xFortify_LeaveScope(pszSrcFile, __LINE__);
     94# endif
    8895    WinTerminate(hab2);
    8996  }
  • trunk/dll/wrappers.c

    r1011 r1032  
    3232#include "errutil.h"                    // Dos_Error...
    3333#include "strutil.h"                    // GetPString
     34#include "command.h"
     35#include "tools.h"
     36#include "avl.h"
    3437
    3538#include "fortify.h"                    // GetPString
     
    403406}
    404407
    405 #pragma alloc_text(WRAPPERS1,xfree,xfopen,xfsopen,xmalloc,xrealloc, xstrdup)
    406 #pragma alloc_text(WRAPPERS2,xDosSetPathInfo,xDosFindFirst,xDosFindNext)
     408# ifdef FORTIFY
     409unsigned char xFortify_LeaveScope(PCSZ pszSrcFile, UINT uiLineNumber)
     410{
     411  unsigned char ret;
     412
     413  free_commands();
     414  free_associations();
     415  free_udir();
     416  free_ldir();
     417  free_archivers();
     418  free_tools();
     419  ret = Fortify_LeaveScope(pszSrcFile, uiLineNumber);
     420  load_commands();
     421  load_udirs();
     422  return ret;
     423}
     424# endif
     425
     426#pragma alloc_text(WRAPPERS1,xfree,xfopen,xfsopen,xmalloc,xrealloc,xstrdup)
     427#pragma alloc_text(WRAPPERS2,xDosSetPathInfo,xDosFindFirst,xDosFindNext,xFortify_LeaveScope)
Note: See TracChangeset for help on using the changeset viewer.