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
294294
295295 md5 = av_md5_alloc();
296296 if (!md5) {
297+ av_frame_free(&frame);
297298 fprintf(stderr, "Error allocating the MD5 context\n");
298299 return 1;
299300 }
@@ -301,8 +302,10 @@ int main(int argc, char *argv[]) · 1 unmodified line
301302 /* Set up the filtergraph. */
302303 err = init_filter_graph(&graph, &src, &sink);
303304 if (err < 0) {
305+ av_frame_free(&frame);
306+ av_freep(&md5);
304307 fprintf(stderr, "Unable to init filter graph:");
305− goto fail;
308+ return 1;
306309 }
307310
308311 /* the main filtering loop */
@@ -353,6 +356,10 @@ int main(int argc, char *argv[]) · 44 unmodified lines
353356 return 0;
354357
355358 fail:
359+ avfilter_graph_free(&graph);
360+ av_frame_free(&frame);
361+ av_freep(&md5);
362+
356363 fprintf(stderr, "%s\n", av_err2str(err));
357364 return 1;
358365 }

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