[kernel] Check for nullptr after gfx_create_surface_from_display If gfx_create_surface_from_display fails to allocate memory it'll return nullptr. If this happens we're hosed, but it's better to fail an assert than dereference a nullptr. Test: booted Eve w/ gfxconsole.early, then "k gfx rgb_bars" Change-Id: Ibdcfcf05800ab40a7cd37602877672a5688f4eef
diff --git a/kernel/lib/gfx/gfx.cpp b/kernel/lib/gfx/gfx.cpp index b4f29a0..16bd503 100644 --- a/kernel/lib/gfx/gfx.cpp +++ b/kernel/lib/gfx/gfx.cpp
@@ -639,6 +639,7 @@ return; gfx_surface* surface = gfx_create_surface_from_display(&info); + DEBUG_ASSERT(surface != nullptr); uint x, y; for (y = 0; y < surface->height; y++) { @@ -667,6 +668,7 @@ return; gfx_surface* surface = gfx_create_surface_from_display(&info); + DEBUG_ASSERT(surface != nullptr); uint x, y; for (y = 0; y < surface->height; y++) { @@ -734,6 +736,7 @@ } gfx_surface* surface = gfx_create_surface_from_display(&info); + DEBUG_ASSERT(surface != nullptr); if (!strcmp(argv[1].str, "display_info")) { printf("display:\n");