OpenGL: Fix null calloc/memcpy

This commit is contained in:
Vicki Pfau 2023-02-11 21:08:31 -08:00
parent 5558e469e0
commit 8c5ad62dbc
1 changed files with 5 additions and 2 deletions

View File

@ -1010,8 +1010,11 @@ bool mGLES2ShaderLoad(struct VideoShader* shader, struct VDir* dir) {
} }
} }
u = mGLES2UniformListSize(&uniformVector); u = mGLES2UniformListSize(&uniformVector);
struct mGLES2Uniform* uniformBlock = calloc(u, sizeof(*uniformBlock)); struct mGLES2Uniform* uniformBlock;
memcpy(uniformBlock, mGLES2UniformListGetPointer(&uniformVector, 0), sizeof(*uniformBlock) * u); if (u) {
uniformBlock = calloc(u, sizeof(*uniformBlock));
memcpy(uniformBlock, mGLES2UniformListGetPointer(&uniformVector, 0), sizeof(*uniformBlock) * u);
}
mGLES2UniformListDeinit(&uniformVector); mGLES2UniformListDeinit(&uniformVector);
mGLES2ShaderInit(&shaderBlock[n], vssrc, fssrc, width, height, scaling, uniformBlock, u); mGLES2ShaderInit(&shaderBlock[n], vssrc, fssrc, width, height, scaling, uniformBlock, u);