Skip to content

Commit 18c2f70

Browse files
Add more ifs and =nullptrs in destroy
1 parent 129cf13 commit 18c2f70

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

src/yolov8_postprocess.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,26 @@ static int create_yolov8_model(YoloModelCtx *ctx, ni_network_data_t *network_dat
149149
}
150150

151151
static void destroy_yolov8_model(YoloModelCtx *ctx) {
152-
if (ctx->out_tensor) {
153-
int i;
154-
for (i = 0; i < ctx->output_number; i++) {
155-
free(ctx->out_tensor[i]);
156-
//free(ctx->layers[i].biases);
157-
//ctx->layers[i].biases = nullptr;
158-
}
159-
free(ctx->out_tensor);
160-
ctx->out_tensor = nullptr;
152+
if (ctx->out_tensor) {
153+
for (int i = 0; i < ctx->output_number; i++) {
154+
if (ctx->out_tensor[i]) {
155+
free(ctx->out_tensor[i]);
156+
ctx->out_tensor[i] = nullptr;
157+
}
158+
//free(ctx->layers[i].biases);
159+
//ctx->layers[i].biases = nullptr;
161160
}
161+
free(ctx->out_tensor);
162+
ctx->out_tensor = nullptr;
163+
}
164+
if (ctx->det_cache.dets) {
162165
free(ctx->det_cache.dets);
166+
ctx->det_cache.dets = nullptr;
167+
}
168+
if (ctx->layers) {
163169
free(ctx->layers);
164170
ctx->layers = nullptr;
171+
}
165172
}
166173

167174
YoloModel yolov8 = {

0 commit comments

Comments
 (0)