Memory handling
V630 The ‘malloc’ function is used to allocate memory for an array of objects which are classes containing constructors. PDFWriter.cpp 117
status_t PDFWriter::PrintPage(int32 pageNumber, int32 pageCount) { .... pictures = (BPicture **)malloc(pictureCount * sizeof(BPicture *)); picRects = (BRect *)malloc(pictureCount * sizeof(BRect)); picPoints = (BPoint *)malloc(pictureCount * sizeof(BPoint)); picRegion = new BRegion(); .... }
When using malloc to allocate memory for an array of objects of some class, neither a constructor is called when creating an object, nor a destructor is called when destroying it. Code like this may result in handing uninitialized variables and other issues.
Please click here to see more bugs from this project.