Changeset 3384 for trunk


Ignore:
Timestamp:
Jun 10, 2007, 1:12:12 PM (18 years ago)
Author:
bird
Message:

Count the whole environment. Fixes #170. pulIdSession and ppid can be NULL, don't crash if they are and pass the correct values to DosStartSession. Fixes #169.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/src/libos2/safe/SafeDosStartSession.c

    r1756 r3384  
    8484    if (SAFE_IS_HIGH(Environment))
    8585    {
    86         l4 = strlen((const char *)Environment) + 1;
     86        const char *psz = Environment;
     87        while (*psz)
     88            psz = strchr(psz, '\0') + 1;
     89        l4 = psz - Environment + 1;
    8790        cbSafe += l4;
    8891    }
     
    149152        pchSafeMem = NULL;
    150153
    151     rc = DosStartSession(psd, &ulIdSession, &pid);
     154    rc = DosStartSession(psd,
     155                         pulIdSession ? &ulIdSession : NULL,
     156                         ppid ? &pid : NULL);
    152157
    153158    /** @todo One should *NOT* modify the input structure but make a COPY!!! */
     
    160165    psd->IconFile = IconFile;
    161166
    162     /* Save returned values */
     167    /* Set return values */
    163168    if (ObjectBuffLen)
    164169        memcpy(ObjectBuffer, psd->ObjectBuffer, ObjectBuffLen);
    165170    psd->ObjectBuffer = ObjectBuffer;
     171    if (pulIdSession)
    166172    *pulIdSession = ulIdSession;
     173    if (ppid)
    167174    *ppid = pid;
    168175
    169     if (pchSafeMem) free( pchSafeMem );
     176    /* cleanup and return. */
     177    if (pchSafeMem)
     178        free(pchSafeMem);
    170179    return rc;
    171180
Note: See TracChangeset for help on using the changeset viewer.