[PATCH weston v1] headless-backend: fix leak of transfrom configuration

Pekka Paalanen ppaalanen at gmail.com
Mon May 2 09:54:56 UTC 2016


On Fri, 29 Apr 2016 16:03:33 -0700
Bryce Harrington <bryce at osg.samsung.com> wrote:

> On Fri, Apr 29, 2016 at 03:36:49PM +0200, Quentin Glidic wrote:
> > On 29/04/2016 15:21, Benoit Gschwind wrote:  
> > >Signed-off-by: Benoit Gschwind <gschwind at gnu-log.net>
> > >---
> > >v1:
> > > - fix warning for freeing a const
> > > - fix typo
> > >
> > > src/main.c | 10 +++++++---
> > > 1 file changed, 7 insertions(+), 3 deletions(-)
> > >
> > >diff --git a/src/main.c b/src/main.c
> > >index f034dda..404e5fc 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";
> > >+	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;  
> > 
> > [3] … and the default would be kept in weston_parse_transform only.
> > 
> >   
> > >+	if (transform) {  
> > 
> > [1] I’d put that check in weston_parse_transform, surrounding the for
> > loop …
> > 
> >   
> > >+		if (weston_parse_transform(transform, &config.transform) < 0)
> > >+			weston_log("Invalid transform \"%s\"\n", transform);
> > >+		free(transform);  
> > 
> > [2] … and as free() is fine on NULL, no more need for that check
> > here at all …  
> 
> That would be okay, but I think the code's fine as is -- Wayland often
> seems to generally rely on callers to do the null pointer checking as is
> being done here.
> 
> I do like the idea of keeping the default local to the parsing routine,
> but I'd rather get the fix landed and do code tidying another time.

Right!

So, pushed:
   4c72e29..2da6d0c  master -> master

I fixed the typo in the subject, too.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160502/726f7c53/attachment.sig>


More information about the wayland-devel mailing list