Changeset 196


Ignore:
Timestamp:
Jan 18, 2011 6:47:19 AM (9 years ago)
Author:
kulshres
Message:

Correct pointer dereference while testing for allocation

Reported-and-Tested-by: Andrey Romanenko <andrey.romanenko@…>
Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/src/sparse/sparsedrivers.cpp

    r193 r196  
    378378    /* recover compressed Jacobian => ColPack library */
    379379 
    380     if (values != NULL && rind != NULL && cind != NULL) {
     380    if (*values != NULL && *rind != NULL && *cind != NULL) {
    381381      // everything is preallocated, we assume correctly
    382382      // call usermem versions
     
    388388      // at least one of rind cind values is not allocated, deallocate others
    389389      // and call unmanaged versions
    390       if (values != NULL)
    391           free(values);
    392       if (rind != NULL)
    393           free(rind);
    394       if (cind != NULL)
    395           free(cind);
     390      if (*values != NULL)
     391          free(*values);
     392      if (*rind != NULL)
     393          free(*rind);
     394      if (*cind != NULL)
     395          free(*cind);
    396396      if (options[3] == 1)
    397397       jr1d->RecoverD2Row_CoordinateFormat_unmanaged(g, sJinfos.B, sJinfos.JP, rind, cind, values);
     
    605605//        HessianRecovery::DirectRecover_CoordinateFormat(g, sHinfos.Hcomp, sHinfos.HP, rind, cind, values);
    606606 
    607     if (values != NULL && rind != NULL && cind != NULL) {
     607    if (*values != NULL && *rind != NULL && *cind != NULL) {
    608608     // everything is preallocated, we assume correctly
    609609     // call usermem versions
     
    615615      // at least one of rind cind values is not allocated, deallocate others
    616616      // and call unmanaged versions
    617       if (values != NULL)
    618           free(values);
    619       if (rind != NULL)
    620           free(rind);
    621       if (cind != NULL)
    622           free(cind);
     617      if (*values != NULL)
     618          free(*values);
     619      if (*rind != NULL)
     620          free(*rind);
     621      if (*cind != NULL)
     622          free(*cind);
    623623     if (options[1] == 0)
    624624       hr->IndirectRecover_CoordinateFormat_unmanaged(g, sHinfos.Hcomp, sHinfos.HP, rind, cind, values);
Note: See TracChangeset for help on using the changeset viewer.