Framebuffer: don't crash is drmModeGetFB() returns 0
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 20 Jun 2016 05:46:57 +0000 (08:46 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 20 Jun 2016 05:46:57 +0000 (08:46 +0300)
kms++/src/framebuffer.cpp

index 1ce8f2a0070cd31a15dca65cfa6e63a54e695c23..39c4e163be287ff3cb54426cac712e287b2abbf2 100644 (file)
@@ -23,10 +23,14 @@ Framebuffer::Framebuffer(Card& card, uint32_t id)
 {
        auto fb = drmModeGetFB(card.fd(), id);
 
-       m_width = fb->width;
-       m_height = fb->height;
-
-       drmModeFreeFB(fb);
+       if (fb) {
+               m_width = fb->width;
+               m_height = fb->height;
+
+               drmModeFreeFB(fb);
+       } else {
+               m_width = m_height = 0;
+       }
 
        card.m_framebuffers.push_back(this);
 }