[PATCH 4/4] graphic_utils: always initialize offscreenbuf member

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox


[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux