Patchwork [1/1] python magic: Fix memory leak caused by not closing loaded file magic

login
register
mail settings
Submitter Morten Svendsen
Date Nov. 1, 2012, 10:35 p.m.
Message ID <4287a6e6d3205909386770a4aa1f6a3438ec017a.1351808899.git.morten.thunbergsvendsen@prevas.dk>
Download mbox | patch
Permalink /patch/196399/
State Accepted
Headers show

Comments

Morten Svendsen - Nov. 1, 2012, 10:35 p.m.
---
 classes/core.oeclass     |    1 +
 classes/image-qa.oeclass |    1 +
 2 files changed, 2 insertions(+)
Esben Haabendal - Dec. 14, 2012, 5:50 p.m.
Morten Thunberg Svendsen <morten.thunbergsvendsen@prevas.dk> writes:

> ---
>  classes/core.oeclass     |    1 +
>  classes/image-qa.oeclass |    1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/classes/core.oeclass b/classes/core.oeclass
> index 394d69b..cb90a6d 100644
> --- a/classes/core.oeclass
> +++ b/classes/core.oeclass
> @@ -144,6 +144,7 @@ def runstrip(file, d):
>      filemagic = magic.open(magic.MAGIC_NONE)
>      filemagic.load()
>      filetype = filemagic.file(file)
> +    filemagic.close()
>  
>      if not filetype:
>          bb.error("runstrip() unable to determine file type: %s"%(file))
> diff --git a/classes/image-qa.oeclass b/classes/image-qa.oeclass
> index f5ac5ea..35dbebc 100644
> --- a/classes/image-qa.oeclass
> +++ b/classes/image-qa.oeclass
> @@ -107,4 +107,5 @@ python do_imageqa () {
>  
>      if readelf_check("HOST") or readelf_check("TARGET"):
>          bb.fatal("libraries missing")
> +    filemagic.close()
>  }

Merged to master, thanks.

/Esben

Patch

diff --git a/classes/core.oeclass b/classes/core.oeclass
index 394d69b..cb90a6d 100644
--- a/classes/core.oeclass
+++ b/classes/core.oeclass
@@ -144,6 +144,7 @@  def runstrip(file, d):
     filemagic = magic.open(magic.MAGIC_NONE)
     filemagic.load()
     filetype = filemagic.file(file)
+    filemagic.close()
 
     if not filetype:
         bb.error("runstrip() unable to determine file type: %s"%(file))
diff --git a/classes/image-qa.oeclass b/classes/image-qa.oeclass
index f5ac5ea..35dbebc 100644
--- a/classes/image-qa.oeclass
+++ b/classes/image-qa.oeclass
@@ -107,4 +107,5 @@  python do_imageqa () {
 
     if readelf_check("HOST") or readelf_check("TARGET"):
         bb.fatal("libraries missing")
+    filemagic.close()
 }