mv_machine_learning: bug fix for memory leak
authorVibhav Aggarwal <v.aggarwal@samsung.com>
Thu, 30 Nov 2023 10:45:40 +0000 (19:45 +0900)
committerKwanghoon Son <k.son@samsung.com>
Wed, 6 Dec 2023 01:36:46 +0000 (10:36 +0900)
[Issue type] bug fix

In SimpleShot::configureModel() function, old model was not
being destroyed before creating the new model. This led to
memory leak detected by ASAN. This patch fixes the issue.

Change-Id: I6a8c3bf3df50c4b1eb39f2e7c94c777b39633323
Signed-off-by: Vibhav Aggarwal <v.aggarwal@samsung.com>
mv_machine_learning/face_recognition/src/simple_shot.cpp

index be00470..eb6c0a0 100644 (file)
@@ -74,6 +74,8 @@ SimpleShot::~SimpleShot()
 void SimpleShot::configureModel(int num_of_class)
 {
        // TODO. Check the capacity.
+       if (_model)
+               _training->DestroyModel(_model.get());
 
        _model = _training->CreateModel();
        if (!_model)