Fix T89782: Segfault populating popup menu with dimensions above the opengl limit

The crash happens because `GPU_offscreen_create` is called with `err_out` `NULL`.

This patch proposes a solution within the `GPU_offscreen_create` itself
and raises an error report in the interface if a menu is called with
dimensions beyond what is supported.

Ref T89782

Maniphest Tasks: T89782

Differential Revision: https://developer.blender.org/D11927
This commit is contained in:
Germano Cavalcante 2021-07-14 20:38:18 -03:00
parent e78e235cc5
commit 15cfb375a3
Notes: blender-bot 2023-02-14 07:31:34 +01:00
Referenced by issue #89782, Segfault populating popup menu with specific structure, `scale_x`, and element count. (GPUOffScreen buffer too large?)
2 changed files with 8 additions and 1 deletions

View File

@ -609,7 +609,13 @@ GPUOffScreen *GPU_offscreen_create(
}
if ((depth && !ofs->depth) || !ofs->color) {
BLI_snprintf(err_out, 256, "GPUTexture: Texture allocation failed.");
const char error[] = "GPUTexture: Texture allocation failed.";
if (err_out) {
BLI_snprintf(err_out, 256, error);
}
else {
fprintf(stderr, error);
}
GPU_offscreen_free(ofs);
return nullptr;
}

View File

@ -457,6 +457,7 @@ static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_
GPUOffScreen *offscreen = GPU_offscreen_create(
region->winx, region->winy, false, false, NULL);
if (!offscreen) {
WM_report(RPT_ERROR, "Region could not be drawn!");
return;
}