[PATCH] headless-backend: fix leak of transfrom configuration
Bryce Harrington
bryce at osg.samsung.com
Fri Apr 29 04:16:26 UTC 2016
On Thu, Apr 28, 2016 at 08:44:54PM -0500, Yong Bakos wrote:
> On Apr 28, 2016, at 1:57 PM, Benoit Gschwind <gschwind at gnu-log.net> wrote:
> >
> > Signed-off-by: Benoit Gschwind <gschwind at gnu-log.net>
> > ---
> > src/main.c | 10 +++++++---
> > 1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/main.c b/src/main.c
> > index f034dda..9c15b71 100644
> > --- a/src/main.c
> > +++ b/src/main.c
> > @@ -692,7 +692,7 @@ load_headless_backend(struct weston_compositor *c, char const * backend,
> > {
> > struct weston_headless_backend_config config = {{ 0, }};
> > int ret = 0;
> > - const char *transform = "normal";
> > + const char *transform = NULL;
> >
> > config.width = 1024;
> > config.height = 640;
> > @@ -706,8 +706,12 @@ load_headless_backend(struct weston_compositor *c, char const * backend,
> >
> > parse_options(options, ARRAY_LENGTH(options), argc, argv);
> >
> > - if (weston_parse_transform(transform, &config.transform) < 0)
> > - weston_log("Invalid transform \"%s\"\n", transform);
> > + config.transform = WL_OUTPUT_TRANSFORM_NORMAL;
> > + if(transform) {
>
> if (
>
> Also note the minor misspelling in the commit message, for v2.
Ditto here. The rest looks correct though, so with those two things
fixed:
Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>
> I would also love to see a short description added to the commit message that
> briefly explains the leak and what the fix accomplishes. (But I'm a noob, so
> if it's obvious, never mind me.)
Leaks are a common enough fault that I don't think anything special
needs to be said.
Basically, within the parse_options() routine if there are string
arguments provided, then a strdup() is performed which allocates a copy
of the string and returns it. The caller is responsible for freeing the
string when done with it. This code in load_headless_backend() was not
freeing the string, so Benoit's above patch corrects that.
Bryce
> yong
>
>
> > + if (weston_parse_transform(transform, &config.transform) < 0)
> > + weston_log("Invalid transform \"%s\"\n", transform);
> > + free(transform);
> > + }
> >
> > config.base.struct_version = WESTON_HEADLESS_BACKEND_CONFIG_VERSION;
> > config.base.struct_size = sizeof(struct weston_headless_backend_config);
> > --
> > 2.7.3
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list