[PATCH 4/4] graphic_utils: always initialize offscreenbuf member
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Mon Jan 14 09:30:51 EST 2013
On 02:54 Mon 14 Jan , Daniel Mierswa wrote:
> If offscreen was not passed to the function the resulting
> offscreenbuf was a dangling pointer and the free() call
> in fd_close would result in undefined behaviour.
>
> Signed-off-by: Daniel Mierswa <d.mierswa at phytec.de>
> ---
> lib/gui/graphic_utils.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
> index 3800ee2..79200de 100644
> --- a/lib/gui/graphic_utils.c
> +++ b/lib/gui/graphic_utils.c
> @@ -226,6 +226,8 @@ int fb_open(const char * fbdev, struct screen *sc, bool offscreen)
> * on the framebuffer
> */
> sc->offscreenbuf = malloc(sc->fbsize);
> + } else {
> + sc->offscreenbuf = NULL;
> }
no you do not touch the struct if we do not ask you a offscreen
the one that call fb_open need to init the struct screen
Best Regards,
J.
More information about the barebox
mailing list