Memoryleak in ScanDraiD::processSingleFrame()

Bug #337907 reported by quirxi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ScanDraiD
Fix Released
High
quirxi

Bug Description

The code is in line 106:

101 float* ScanDraiD::processSingleFrame(const std::string& fileName, const unsigned int frameNr) const
102 {
103 scanDraiD::Jpeg* jpg = new scanDraiD::Jpeg;
104 jpg->load(fileName.c_str());
105 numberPoints_ = jpg->getHeight() / lineSkip_;
106 float* res = new float[3 * numberPoints_];
107 float frame_angle = ((float) frameNr) * (360.0f / (float) numberFrames_);

It would probably be better to use std::vector instead of an array of floats!

Here is the output of valgrind:

> valgrind --leak-check=full ./ScanDraiD.exe -i=../../ToolsAndDocs/examples/pics -o=out3d.ac
==22613== Memcheck, a memory error detector.
==22613== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
==22613== Using LibVEX rev 1878, a library for dynamic binary translation.
==22613== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
==22613== Using valgrind-3.4.0, a dynamic binary instrumentation framework.
==22613== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
==22613== For more details, rerun with: -v
==22613==
==22613== frame 360/360: '../../ToolsAndDocs/examples/pics/00000359.jpg'
==22613== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 7 from 1)
==22613== malloc/free: in use at exit: 1,728,000 bytes in 360 blocks.
==22613== malloc/free: 6,902 allocs, 6,542 frees, 191,107,889 bytes allocated.
==22613== For counts of detected errors, rerun with: -v
==22613== searching for pointers to 360 not-freed blocks.
==22613== checked 94,680 bytes.
==22613==
==22613== 1,728,000 bytes in 360 blocks are definitely lost in loss record 1 of 1
==22613== at 0x40237AF: operator new[](unsigned int) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==22613== by 0x804BCB0: scanDraiD::ScanDraiD::processSingleFrame(std::string const&, unsigned int) const (ScanDraiD.cpp:106)
==22613== by 0x804D82C: scanDraiD::ScanDraiD::processFrames(std::string const&, std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&) (ScanDraiD.cpp:184)
==22613== by 0x80505F7: main (main.cpp:217)
==22613==
==22613== LEAK SUMMARY:
==22613== definitely lost: 1,728,000 bytes in 360 blocks.
==22613== possibly lost: 0 bytes in 0 blocks.
==22613== still reachable: 0 bytes in 0 blocks.
==22613== suppressed: 0 bytes in 0 blocks.

Related branches

quirxi (a-w)
Changed in scandraid:
assignee: nobody → a-w
importance: Undecided → High
milestone: none → 01.alpha
quirxi (a-w)
Changed in scandraid:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.