History

examples: Add proper deallocations to avoid potential memory leaks

Add proper deallocations in the error paths to avoid potential memory leaks.

Jiasheng Jiang committed 1 year ago

Commit 39592f21 parent 8b4e6cc1 file · +8 −1Browse files

Unified · Split

doc/examples/filter_audio.c+8−1
@@ -294,6 +294,7 @@ int main(int argc, char *argv[]) · 293 unmodified lines
294 294
295 md5 = av_md5_alloc();295 md5 = av_md5_alloc();
296 if (!md5) {296 if (!md5) {
297 av_frame_free(&frame);
297 fprintf(stderr, "Error allocating the MD5 context\n");298 fprintf(stderr, "Error allocating the MD5 context\n");
298 return 1;299 return 1;
299 }300 }
@@ -301,8 +302,10 @@ int main(int argc, char *argv[]) · 1 unmodified line
301 /* Set up the filtergraph. */302 /* Set up the filtergraph. */
302 err = init_filter_graph(&graph, &src, &sink);303 err = init_filter_graph(&graph, &src, &sink);
303 if (err < 0) {304 if (err < 0) {
305 av_frame_free(&frame);
306 av_freep(&md5);
304 fprintf(stderr, "Unable to init filter graph:");307 fprintf(stderr, "Unable to init filter graph:");
305 goto fail;308 return 1;
306 }309 }
307 310
308 /* the main filtering loop */311 /* the main filtering loop */
@@ -353,6 +356,10 @@ int main(int argc, char *argv[]) · 44 unmodified lines
353 return 0;356 return 0;
354 357
355fail:358fail:
359 avfilter_graph_free(&graph);
360 av_frame_free(&frame);
361 av_freep(&md5);
362
356 fprintf(stderr, "%s\n", av_err2str(err));363 fprintf(stderr, "%s\n", av_err2str(err));
357 return 1;364 return 1;
358}365}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t