Changeset 27 for rxprtutl


Ignore:
Timestamp:
Aug 2, 2015, 3:52:53 AM (10 years ago)
Author:
Alex Taylor
Message:

Fixed memory leak in writing of compound variables; removed erroneous DosFreeMem from SaveResultString.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rxprtutl/trunk/rxprtutl.c

    r15 r27  
    20392039            return ( FALSE );
    20402040        }
    2041         DosFreeMem( prsResult->strptr );
    20422041        prsResult->strptr = pchNew;
    20432042    }
     
    20682067    ULONG    ulRc,
    20692068             ulBytes;
    2070     CHAR     szCompoundName[ US_COMPOUND_MAXZ ],
    2071             *pchValue;
     2069    CHAR     szCompoundName[ US_COMPOUND_MAXZ ];
    20722070
    20732071    sprintf( szCompoundName, "%s.%d", pszStem, ulIndex );
    20742072    if ( pszValue == NULL ) {
    2075         pchValue = "";
     2073        pszValue = "";
    20762074        ulBytes  = 0;
    20772075    } else {
    20782076        ulBytes = strlen( pszValue );
    2079         ulRc = DosAllocMem( (PVOID) &pchValue, ulBytes + 1, PAG_WRITE | PAG_COMMIT );
    2080         if ( ulRc != 0 ) {
    2081             WriteErrorCode( ulRc, "DosAllocMem");
    2082             return FALSE;
    2083         }
    2084         memcpy( pchValue, pszValue, ulBytes );
    20852077    }
    20862078    MAKERXSTRING( shvVar.shvname, szCompoundName, strlen(szCompoundName) );
    2087     shvVar.shvvalue.strptr    = pchValue;
     2079    shvVar.shvvalue.strptr    = pszValue;
    20882080    shvVar.shvvalue.strlength = ulBytes;
    20892081    shvVar.shvnamelen  = RXSTRLEN( shvVar.shvname );
     
    21202112    ULONG    ulRc,
    21212113             ulBytes;
    2122     CHAR     szCompoundName[ US_COMPOUND_MAXZ ],
    2123             *pchValue;
     2114    CHAR     szCompoundName[ US_COMPOUND_MAXZ ];
    21242115
    21252116    sprintf( szCompoundName, "%s.%s", pszStem, pszTail );
    21262117    if ( pszValue == NULL ) {
    2127         pchValue = "";
     2118        pszValue = "";
    21282119        ulBytes  = 0;
    21292120    } else {
    21302121        ulBytes = strlen( pszValue );
    2131         ulRc = DosAllocMem( (PVOID) &pchValue, ulBytes + 1, PAG_WRITE | PAG_COMMIT );
    2132         if ( ulRc != 0 ) {
    2133             WriteErrorCode( ulRc, "DosAllocMem");
    2134             return FALSE;
    2135         }
    2136         memcpy( pchValue, pszValue, ulBytes );
    21372122    }
    21382123    MAKERXSTRING( shvVar.shvname, szCompoundName, strlen(szCompoundName) );
    2139     shvVar.shvvalue.strptr    = pchValue;
     2124    shvVar.shvvalue.strptr    = pszValue;
    21402125    shvVar.shvvalue.strlength = ulBytes;
    21412126    shvVar.shvnamelen  = RXSTRLEN( shvVar.shvname );
Note: See TracChangeset for help on using the changeset viewer.