Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v3 1/2] fate/imf: fix memory leak
@ 2023-05-15 18:32 pal
  2023-05-15 18:33 ` [FFmpeg-devel] [PATCH v3 2/2] fate/imf: remove redundant code pal
  2023-05-18 22:16 ` [FFmpeg-devel] [PATCH v3 1/2] fate/imf: fix memory leak Pierre-Anthony Lemieux
  0 siblings, 2 replies; 3+ messages in thread
From: pal @ 2023-05-15 18:32 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Pierre-Anthony Lemieux

From: Pierre-Anthony Lemieux <pal@palemieux.com>

---
 libavformat/tests/imf.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c
index cfd84fb8c8..c02cd87ceb 100644
--- a/libavformat/tests/imf.c
+++ b/libavformat/tests/imf.c
@@ -402,6 +402,9 @@ static int test_bad_cpl_parsing(FFIMFCPL **cpl)
         return ret;
     }
 
+    ff_imf_cpl_free(*cpl);
+    *cpl = NULL;
+
     return 0;
 }
 
@@ -423,6 +426,9 @@ static int test_bad_resource_cpl_parsing(FFIMFCPL **cpl)
         return ret;
     }
 
+    ff_imf_cpl_free(*cpl);
+    *cpl = NULL;
+
     return 0;
 }
 
@@ -594,8 +600,11 @@ int main(int argc, char *argv[])
     printf("#### End failing test ####\n");
 
     printf("#### The following should emit errors ####\n");
-    if (test_bad_resource_cpl_parsing(&cpl) != 0)
+    if (test_bad_resource_cpl_parsing(&cpl) != 0) {
+        if (cpl)
+            printf("Improper cleanup after failed CPL parsing\n");
         ret = 1;
+    }
     printf("#### End emission of errors ####\n");
 
     return ret;
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] [PATCH v3 2/2] fate/imf: remove redundant code
  2023-05-15 18:32 [FFmpeg-devel] [PATCH v3 1/2] fate/imf: fix memory leak pal
@ 2023-05-15 18:33 ` pal
  2023-05-18 22:16 ` [FFmpeg-devel] [PATCH v3 1/2] fate/imf: fix memory leak Pierre-Anthony Lemieux
  1 sibling, 0 replies; 3+ messages in thread
From: pal @ 2023-05-15 18:33 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Pierre-Anthony Lemieux

From: Pierre-Anthony Lemieux <pal@palemieux.com>

---
 libavformat/tests/imf.c | 52 ++++++++++-------------------------------
 1 file changed, 12 insertions(+), 40 deletions(-)

diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c
index c02cd87ceb..068ee6c58a 100644
--- a/libavformat/tests/imf.c
+++ b/libavformat/tests/imf.c
@@ -257,7 +257,7 @@ const char *cpl_doc =
     "</SegmentList>"
     "</CompositionPlaylist>";
 
-const char *cpl_bad_doc = "<Composition></Composition>";
+const char *cpl_bad_empty_doc = "<Composition></Composition>";
 
 const char *asset_map_doc =
     "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
@@ -384,52 +384,31 @@ static int test_cpl_parsing(void)
     return 0;
 }
 
-static int test_bad_cpl_parsing(FFIMFCPL **cpl)
-{
-    xmlDocPtr doc;
-    int ret;
-
-    doc = xmlReadMemory(cpl_bad_doc, strlen(cpl_bad_doc), NULL, NULL, 0);
-    if (doc == NULL) {
-        printf("XML parsing failed.\n");
-        return 1;
-    }
-
-    ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl);
-    xmlFreeDoc(doc);
-    if (ret) {
-        printf("CPL parsing failed.\n");
-        return ret;
-    }
-
-    ff_imf_cpl_free(*cpl);
-    *cpl = NULL;
-
-    return 0;
-}
-
-static int test_bad_resource_cpl_parsing(FFIMFCPL **cpl)
-{
+static int test_cpl_from_doc(FFIMFCPL **cpl, const char* cpl_doc, int should_pass) {
     xmlDocPtr doc;
     int ret;
 
-    doc = xmlReadMemory(cpl_bad_resource_doc, strlen(cpl_bad_resource_doc), NULL, NULL, 0);
+    doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0);
     if (doc == NULL) {
         printf("XML parsing failed.\n");
-        return 1;
+        return should_pass;
     }
 
     ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl);
     xmlFreeDoc(doc);
     if (ret) {
         printf("CPL parsing failed.\n");
-        return ret;
+        if (*cpl) {
+            printf("Improper cleanup after failed CPL parsing\n");
+            return 1;
+        }
+        return should_pass;
     }
 
     ff_imf_cpl_free(*cpl);
     *cpl = NULL;
 
-    return 0;
+    return !should_pass;
 }
 
 static int check_asset_locator_attributes(IMFAssetLocator *asset, IMFAssetLocator *expected_asset)
@@ -591,20 +570,13 @@ int main(int argc, char *argv[])
         ret = 1;
 
     printf("#### The following should fail ####\n");
-    if (test_bad_cpl_parsing(&cpl) == 0) {
+    if (test_cpl_from_doc(&cpl, cpl_bad_empty_doc, 0) != 0)
         ret = 1;
-    } else if (cpl) {
-        printf("Improper cleanup after failed CPL parsing\n");
-        ret = 1;
-    }
     printf("#### End failing test ####\n");
 
     printf("#### The following should emit errors ####\n");
-    if (test_bad_resource_cpl_parsing(&cpl) != 0) {
-        if (cpl)
-            printf("Improper cleanup after failed CPL parsing\n");
+    if (test_cpl_from_doc(&cpl, cpl_bad_resource_doc, 1) != 0)
         ret = 1;
-    }
     printf("#### End emission of errors ####\n");
 
     return ret;
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 1/2] fate/imf: fix memory leak
  2023-05-15 18:32 [FFmpeg-devel] [PATCH v3 1/2] fate/imf: fix memory leak pal
  2023-05-15 18:33 ` [FFmpeg-devel] [PATCH v3 2/2] fate/imf: remove redundant code pal
@ 2023-05-18 22:16 ` Pierre-Anthony Lemieux
  1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Anthony Lemieux @ 2023-05-18 22:16 UTC (permalink / raw)
  To: ffmpeg-devel

Will apply shortly.

On Mon, May 15, 2023 at 11:33 AM <pal@sandflow.com> wrote:
>
> From: Pierre-Anthony Lemieux <pal@palemieux.com>
>
> ---
>  libavformat/tests/imf.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c
> index cfd84fb8c8..c02cd87ceb 100644
> --- a/libavformat/tests/imf.c
> +++ b/libavformat/tests/imf.c
> @@ -402,6 +402,9 @@ static int test_bad_cpl_parsing(FFIMFCPL **cpl)
>          return ret;
>      }
>
> +    ff_imf_cpl_free(*cpl);
> +    *cpl = NULL;
> +
>      return 0;
>  }
>
> @@ -423,6 +426,9 @@ static int test_bad_resource_cpl_parsing(FFIMFCPL **cpl)
>          return ret;
>      }
>
> +    ff_imf_cpl_free(*cpl);
> +    *cpl = NULL;
> +
>      return 0;
>  }
>
> @@ -594,8 +600,11 @@ int main(int argc, char *argv[])
>      printf("#### End failing test ####\n");
>
>      printf("#### The following should emit errors ####\n");
> -    if (test_bad_resource_cpl_parsing(&cpl) != 0)
> +    if (test_bad_resource_cpl_parsing(&cpl) != 0) {
> +        if (cpl)
> +            printf("Improper cleanup after failed CPL parsing\n");
>          ret = 1;
> +    }
>      printf("#### End emission of errors ####\n");
>
>      return ret;
> --
> 2.25.1
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-18 22:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-15 18:32 [FFmpeg-devel] [PATCH v3 1/2] fate/imf: fix memory leak pal
2023-05-15 18:33 ` [FFmpeg-devel] [PATCH v3 2/2] fate/imf: remove redundant code pal
2023-05-18 22:16 ` [FFmpeg-devel] [PATCH v3 1/2] fate/imf: fix memory leak Pierre-Anthony Lemieux

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git