mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
fixed memory leak in GBTrees
This commit is contained in:
parent
94cf5430d0
commit
1b8c2589c0
@ -1292,13 +1292,18 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
|
||||
return -FLT_MAX;
|
||||
|
||||
float* pred_resp = 0;
|
||||
bool needsFreeing = false;
|
||||
|
||||
if (resp)
|
||||
{
|
||||
resp->resize(n);
|
||||
pred_resp = &((*resp)[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pred_resp = new float[n];
|
||||
needsFreeing = true;
|
||||
}
|
||||
|
||||
Sample_predictor predictor = Sample_predictor(this, pred_resp, _data->get_values(),
|
||||
_data->get_missing(), _sample_idx);
|
||||
@ -1331,6 +1336,9 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
|
||||
err = err / (float)n;
|
||||
}
|
||||
|
||||
if (needsFreeing)
|
||||
delete[]pred_resp;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user