Fix ubsan warnings about indexing into null pointers

Ref T99382

Differential Revision: https://developer.blender.org/D15390
This commit is contained in:
Loren Osborn 2022-08-19 14:33:55 +02:00 committed by Brecht Van Lommel
parent a06c9b5ca8
commit db46251209
Notes: blender-bot 2023-02-13 23:16:02 +01:00
Referenced by issue #99382, [Parent Task] Fix UBSan issues
1 changed files with 4 additions and 2 deletions

View File

@ -35,9 +35,11 @@ class GLIndexBuf : public IndexBuf {
{
additional_vertex_offset += index_start_;
if (index_type_ == GPU_INDEX_U32) {
return (GLuint *)0 + additional_vertex_offset;
return reinterpret_cast<void *>(static_cast<intptr_t>(additional_vertex_offset) *
sizeof(GLuint));
}
return (GLushort *)0 + additional_vertex_offset;
return reinterpret_cast<void *>(static_cast<intptr_t>(additional_vertex_offset) *
sizeof(GLushort));
}
GLuint restart_index() const