kmansoft / imageresampler

Automatically exported from code.google.com/p/imageresampler
0 stars 0 forks source link

test.cpp leaks memory #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The memory allocated to the resamplers array on line 80 in test.cpp has no 
corresponding call to delete.

80    Resampler* resamplers[max_components]; // memory allocated to this array 
is never deleted                                                                

81    std::vector<float> samples[max_components];                               

82                                                                              

83    resamplers[0] = new Resampler(src_width, src_height, dst_width, 
dst_height, Resampler::BOUNDARY_CLAMP, 0.0f, 1.0f, pFilter, NULL, NULL, 
filter_scale, filter_scale);                                                    

84    samples[0].resize(src_width);                                             

85    for (int i = 1; i < n; i++)                                               

86    {                                                                         

87       resamplers[i] = new Resampler(src_width, src_height, dst_width, 
dst_height, Resampler::BOUNDARY_CLAMP, 0.0f, 1.0f, pFilter, 
resamplers[0]->get_clist_x(), resamplers[0]->get_clist_y(), filter_scale, 
filter_scale);                
88       samples[i].resize(src_width);                                          

89    }

Fixed by adding
for (int = 0; i < n; ++i) { delete resamplers[ i ]; }
before returning from main().

Original issue reported on code.google.com by drt...@gmail.com on 5 Sep 2011 at 7:28

GoogleCodeExporter commented 9 years ago
Thank you very much drtwox - I'll integrate this change and issue a new release.

Original comment by richge...@gmail.com on 20 May 2012 at 2:40