Changeset 2291 for trunk/src


Ignore:
Timestamp:
Jun 23, 2011 1:51:42 PM (13 years ago)
Author:
ldelgass
Message:

Fix mismatched allocation/deletion of field value char arrays. The arrays were
being allocated with new[] and being deleted with the plain delete operator
instead of delete[], which can lead to heap corruption and/or memory leaks.
The problem was found by the cppcheck tool.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/objects/RpParserXML.cc

    r1581 r2291  
    9797            Rp_TreeSetValue(inf->tree,inf->curr,Rp_ParserXml_Field_VALUE,
    9898                (void *)newValue);
    99             delete value;
     99            delete[] value;
    100100            value = NULL;
    101101        }
     
    420420            }
    421421            // free the old data
    422             delete(oldval);
     422            delete[] oldval;
    423423            oldval = NULL;
    424424        }
     
    477477        if (oldval != NULL) {
    478478            // free the old data
    479             delete(oldval);
     479            delete[] oldval;
    480480            oldval = NULL;
    481481        }
     
    491491    n = vsnprintf(stackSpace, stackSize, format, lst);
    492492    if (n >= stackSize) {
    493         delete stackSpace;
     493        delete[] stackSpace;
    494494        stackSpace = new char[n];
    495495        vsnprintf(stackSpace, n, format, lst);
     
    545545    n = vsnprintf(stackSpace, stackSize, format, lst);
    546546    if (n >= stackSize) {
    547         delete stackSpace;
     547        delete[] stackSpace;
    548548        stackSpace = new char[n];
    549549        vsnprintf(stackSpace, n, format, lst);
     
    558558        strcat(newval,stackSpace);
    559559        // free the old data
    560         delete(oldval);
     560        delete[] oldval;
    561561        oldval = NULL;
    562         delete(stackSpace);
     562        delete[] stackSpace;
    563563        stackSpace = NULL;
    564564    }
Note: See TracChangeset for help on using the changeset viewer.