Skip to content

Commit 56979ae

Browse files
committed
fix: ensure proper cleanup of img_res_v.data in all code paths
1 parent 902368a commit 56979ae

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/llava/llava.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static bool encode_image_with_clip(clip_ctx * ctx_clip, int n_threads, const cli
282282

283283
if (!encoded) {
284284
LOG_ERR("Unable to encode image - spatial_unpad - subimage %d of %d\n", (int) i+1, (int) img_res_v.size);
285+
delete[] img_res_v.data; // 添加内存释放
285286
return false;
286287
}
287288
const int64_t t_img_enc_steop_batch_us = ggml_time_us();
@@ -322,6 +323,7 @@ static bool encode_image_with_clip(clip_ctx * ctx_clip, int n_threads, const cli
322323
*n_img_pos = (pos * pos + 2);
323324
if (!encoded){
324325
LOG_ERR("Unable to encode image \n");
326+
delete[] img_res_v.data; // 添加内存释放
325327
return false;
326328
}
327329
}
@@ -346,6 +348,7 @@ static bool encode_image_with_clip(clip_ctx * ctx_clip, int n_threads, const cli
346348
const bool encoded = clip_image_encode(ctx_clip, n_threads, &img_res_v.data[i], image_embd_v[i]); // image data is in 3x336x336 format and will be converted to 336x336x3 inside
347349
if (!encoded) {
348350
LOG_ERR("Unable to encode image - spatial_unpad - subimage %d of %d\n", (int) i+1, (int) img_res_v.size);
351+
delete[] img_res_v.data; // 添加内存释放
349352
return false;
350353
}
351354
}

0 commit comments

Comments
 (0)