IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 8, 2007, 2:50:00 PM (19 years ago)
Author:
Paul Price
Message:

Variable 'path' is on a psMetadataItem, so using "psStringAppend" on
it can invalidate the pointer (if additional memory needs to be
allocated), causing memory corruption because the pointer on the
psMetadataItem no longer points to valid memory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r15469 r15525  
    551551
    552552    psString path = psMetadataLookupStr(NULL, config->site, "PATH");
     553    psString newPath = NULL;            // New path
     554    // The following gymnastics with 'newPath' are required to avoid changing the pointer out from under the
     555    // psMetadataItem on which 'path' sits (leading to memory corruption because it no longer points to valid
     556    // memory).
    553557    if (path) {
    554         psStringAppend(&path, ":%s", siteNameDir);
     558        psStringAppend(&newPath, "%s:%s", path, siteNameDir);
    555559    } else {
    556         path = psMemIncrRefCounter(siteNameDir);
    557     }
    558     pmConfigSet(path);
     560        newPath = psMemIncrRefCounter(siteNameDir);
     561    }
    559562    psFree(siteNameDir);
     563    pmConfigSet(newPath);
     564    psFree(newPath);
    560565
    561566    // Next, we do a similar thing for the camera configuration file.  The
Note: See TracChangeset for help on using the changeset viewer.