diff mbox series

[RFC,v2,23/27] libselinux: free elements on read_spec_entries() failure

Message ID 20230814132025.45364-24-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit 168edd1ca279
Delegated to: Petr Lautrbach
Headers show
Series libselinux: rework selabel_file(5) database | expand

Commit Message

Christian Göttsche Aug. 14, 2023, 1:20 p.m. UTC
Some entries might have been already parsed and allocated.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
v2: add patch
---
 libselinux/src/label_file.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

James Carter Oct. 11, 2023, 6:50 p.m. UTC | #1
On Mon, Aug 14, 2023 at 9:42 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> Some entries might have been already parsed and allocated.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
> v2: add patch
> ---
>  libselinux/src/label_file.h | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h
> index 56439e2d..3827b5c0 100644
> --- a/libselinux/src/label_file.h
> +++ b/libselinux/src/label_file.h
> @@ -446,6 +446,9 @@ static inline int process_line(struct selabel_handle *rec,
>                                     "%s:  line %u error due to: %m\n", path,
>                                     lineno);
>                 }
> +               free(regex);
> +               free(type);
> +               free(context);
>                 return -1;
>         }
>
> --
> 2.40.1
>
James Carter Oct. 12, 2023, 5:56 p.m. UTC | #2
On Wed, Oct 11, 2023 at 2:50 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Aug 14, 2023 at 9:42 AM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > Some entries might have been already parsed and allocated.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>
Merged.
Thanks,
Jim

> > ---
> > v2: add patch
> > ---
> >  libselinux/src/label_file.h | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h
> > index 56439e2d..3827b5c0 100644
> > --- a/libselinux/src/label_file.h
> > +++ b/libselinux/src/label_file.h
> > @@ -446,6 +446,9 @@ static inline int process_line(struct selabel_handle *rec,
> >                                     "%s:  line %u error due to: %m\n", path,
> >                                     lineno);
> >                 }
> > +               free(regex);
> > +               free(type);
> > +               free(context);
> >                 return -1;
> >         }
> >
> > --
> > 2.40.1
> >
diff mbox series

Patch

diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h
index 56439e2d..3827b5c0 100644
--- a/libselinux/src/label_file.h
+++ b/libselinux/src/label_file.h
@@ -446,6 +446,9 @@  static inline int process_line(struct selabel_handle *rec,
 				    "%s:  line %u error due to: %m\n", path,
 				    lineno);
 		}
+		free(regex);
+		free(type);
+		free(context);
 		return -1;
 	}