IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9947


Ignore:
Timestamp:
Nov 9, 2006, 6:05:00 PM (20 years ago)
Author:
jhoblitt
Message:

fix -definebydetrun memory corruption issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/dettool.c

    r9946 r9947  
    135135            psAbort(argv[0], "invalid option (this should not happen)");
    136136    }
    137 psFree(config); pmConfigDone();
     137
     138    psFree(config);
     139    pmConfigDone();
    138140    psLibFinalize();
    139141
     
    832834    if (psArrayLength(detRuns) != 1) {
    833835        psAbort(config->argv[0], "found more then one detRun matching det_id %d(this should not happen)", (psS32)atoi(det_id));
    834         return false;
     836        return false;                   // unreachable
    835837    }
    836838   
     
    858860    }
    859861    if (exp_type) {
    860         detRun->exp_type = exp_type;
     862        psFree(detRun->exp_type);
     863        detRun->exp_type = psStringCopy(exp_type);
    861864    }
    862865
     
    867870    }
    868871    if (filter) {
    869         detRun->filter = filter;
     872        psFree(detRun->filter);
     873        detRun->filter = psStringCopy(filter);
    870874    }
    871875
     
    912916    }
    913917    if (object) {
    914         detRun->object = object;
     918        psFree(detRun->object);
     919        detRun->object = psStringCopy(object);
    915920    }
    916921
     
    924929        // pass through NULL as this is an optional field
    925930        if (registeredStr) {
    926             psFree(registered);
     931            psFree(detRun->registered);
    927932            registered = psTimeFromISO(registeredStr, PS_TIME_UTC);
    928933            detRun->registered = psMemIncrRefCounter(registered);
     
    940945        // pass through NULL as this is an optional field
    941946        if (use_beginStr) {
    942             psFree(use_begin);
     947            psFree(detRun->use_begin);
    943948            use_begin = psTimeFromISO(use_beginStr, PS_TIME_UTC);
    944949            detRun->use_begin = psMemIncrRefCounter(use_begin);
     
    956961        // pass through NULL as this is an optional field
    957962        if (use_endStr) {
    958             psFree(use_end);
     963            psFree(detRun->use_end);
    959964            use_end = psTimeFromISO(use_endStr, PS_TIME_UTC);
    960965            detRun->use_end = psMemIncrRefCounter(use_end);
     
    10151020    }
    10161021
    1017     {
    10181022    // print the new det_id
    1019     psArray *detRuns = NULL;
     1023    psArray *newDetRuns = NULL;
    10201024    {
    10211025        psMetadata *where = psMetadataAlloc();
    10221026        psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==", newDet_id);
    1023         detRuns = psDBSelectRows(config->dbh, "detRun", where, 0);
     1027        newDetRuns = psDBSelectRows(config->dbh, "detRun", where, 0);
    10241028        psFree(where);
    10251029    }
    1026     if (!detRuns) {
     1030    if (!newDetRuns) {
    10271031        psError(PS_ERR_UNKNOWN, false, "can't find the detRun we just created");
    10281032        return false;
    10291033    }
    10301034    // sanity check the result... we should have only found one det_id
    1031     if (psArrayLength(detRuns) != 1) {
     1035    if (psArrayLength(newDetRuns) != 1) {
    10321036        psAbort(config->argv[0], "found more then one detRun matching det_id %ld(this should not happen)", newDet_id);
    1033         return false;
     1037        return false;                   // unreachable
    10341038    }
    10351039
    10361040    // convert det_id to a string externaly
    1037     if (!convertDetIdToStr(detRuns)) {
     1041    if (!convertDetIdToStr(newDetRuns)) {
    10381042        psError(PS_ERR_UNKNOWN, false, "failed to convert det_id to a string");
    1039         psFree(detRuns);
     1043        psFree(newDetRuns);
    10401044        return false;
    10411045    }
    10421046
    10431047    // negative simple so the default is true
    1044     if (!ippdbPrintMetadatas(stdout, detRuns, "detRun", !simple)) {
     1048    if (!ippdbPrintMetadatas(stdout, newDetRuns, "detRun", !simple)) {
    10451049        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    1046         psFree(detRuns);
    1047         return false;
    1048     }
    1049     psFree(detRuns);
    1050     }
     1050        psFree(newDetRuns);
     1051        return false;
     1052    }
     1053    psFree(newDetRuns);
    10511054
    10521055    return true;
Note: See TracChangeset for help on using the changeset viewer.