stepcode/src
Jeff Epler 02910b2d38 Match new[] and delete[]
.. this would otherwise cause a memory use error in the unusual case
where a numeric identifer held more letters than expected.

For instance, passing the following file as the input to tst_inverse_attr3:

ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('SCL test file'),'2;1');
FILE_NAME('test_inverse_attr.p21','2012-06-30T',('mp'),(''),'0','1','2');
FILE_SCHEMA(('test_inverse_attr'));
ENDSEC;
DATA;
ENDSEC;
END-ISO-10303-21;

and running it under valgrind can cause a diagnostic similar to the following to be displayed:
Mismatched free() / delete / delete []
   at 0x4C2D2DB: operator delete(void*) (vg_replace_malloc.c:576)
   by 0x507A5A6: sectionReader::readInstanceNumber() (sectionReader.cc:224)
   by 0x507CCC7: lazyP21DataSectionReader::nextInstance() (lazyP21DataSectionReader.cc:53)
   by 0x507C797: lazyP21DataSectionReader::lazyP21DataSectionReader(lazyFileReader*, std::basic_ifstream<char, std::char_traits<char> >&, std::fpos<__mbstate_t>, unsigned short) (lazyP21DataSectionReader.cc:11)
   by 0x50699F2: lazyFileReader::initP21() (lazyFileReader.cc:14)
   by 0x5069E5D: lazyFileReader::lazyFileReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, lazyInstMgr*, unsigned short) (lazyFileReader.cc:61)
] and delete[]
   by 0x506AAA7: lazyInstMgr::openFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (lazyInstMgr.cc:103)
   by 0x4023A1: main (inverse_attr3.cc:35)
 Address 0x6a861a0 is 0 bytes inside a block of size 21 alloc'd
   at 0x4C2C93F: operator new[](unsigned long) (vg_replace_malloc.c:423)
   by 0x507A3A7: sectionReader::readInstanceNumber() (sectionReader.cc:202)

This problem is also reported in static analysis by clang, and as such can be seen in travis ci build logs.
2017-08-15 21:24:23 -05:00
..
base msvc warnings/errors 2015-08-09 23:29:15 -04:00
cldai fix MSVC link error for NilSTEPentity 2015-08-09 23:30:13 -04:00
cleditor warning about extra parens 2015-06-13 21:13:04 -04:00
cllazyfile Match new[] and delete[] 2017-08-15 21:24:23 -05:00
clstepcore fix #327 - statically initialize t_sdaiINTEGER etc 2015-08-30 11:57:58 -04:00
clutils 'register' storage class specifier is deprecated [-Wdeprecated-register] 2015-08-03 22:00:22 -04:00
exp2cxx Add an option to completely bypass the git management of the version header. 2016-08-06 13:53:12 -04:00
exp2python Fixed typos showing up as ascii chars 2017-03-04 07:22:46 -05:00
exppp improve comments for doxygen 2015-05-20 20:03:47 -04:00
express Add an option to completely bypass the git management of the version header. 2016-08-06 13:53:12 -04:00
test delete makefile fragment 2015-05-20 20:02:09 -04:00