[PATCH 4/4] graphic_utils: always initialize offscreenbuf member
Daniel Mierswa
d.mierswa at phytec.de
Sun Jan 13 20:54:16 EST 2013
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;
}
return sc->fd;
--
1.8.1
More information about the barebox
mailing list