Fix invalid crash in mesh_add_surface
(cherry picked from commit 99ba021404
)
This commit is contained in:
parent
480d87e7c8
commit
e766b16e95
|
@ -3497,7 +3497,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
|
||||||
if (p_vertex_count < (1 << 16)) {
|
if (p_vertex_count < (1 << 16)) {
|
||||||
//read 16 bit indices
|
//read 16 bit indices
|
||||||
const uint16_t *src_idx = (const uint16_t *)ir.ptr();
|
const uint16_t *src_idx = (const uint16_t *)ir.ptr();
|
||||||
for (int i = 0; i < index_count; i += 6) {
|
for (int i = 0; i + 5 < index_count; i += 6) {
|
||||||
|
|
||||||
wr[i + 0] = src_idx[i / 2];
|
wr[i + 0] = src_idx[i / 2];
|
||||||
wr[i + 1] = src_idx[i / 2 + 1];
|
wr[i + 1] = src_idx[i / 2 + 1];
|
||||||
|
@ -3511,7 +3511,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
|
||||||
|
|
||||||
//read 16 bit indices
|
//read 16 bit indices
|
||||||
const uint32_t *src_idx = (const uint32_t *)ir.ptr();
|
const uint32_t *src_idx = (const uint32_t *)ir.ptr();
|
||||||
for (int i = 0; i < index_count; i += 6) {
|
for (int i = 0; i + 5 < index_count; i += 6) {
|
||||||
|
|
||||||
wr[i + 0] = src_idx[i / 2];
|
wr[i + 0] = src_idx[i / 2];
|
||||||
wr[i + 1] = src_idx[i / 2 + 1];
|
wr[i + 1] = src_idx[i / 2 + 1];
|
||||||
|
@ -3527,7 +3527,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
|
||||||
index_count = p_vertex_count * 2;
|
index_count = p_vertex_count * 2;
|
||||||
wf_indices.resize(index_count);
|
wf_indices.resize(index_count);
|
||||||
PoolVector<uint32_t>::Write wr = wf_indices.write();
|
PoolVector<uint32_t>::Write wr = wf_indices.write();
|
||||||
for (int i = 0; i < index_count; i += 6) {
|
for (int i = 0; i + 5 < index_count; i += 6) {
|
||||||
|
|
||||||
wr[i + 0] = i / 2;
|
wr[i + 0] = i / 2;
|
||||||
wr[i + 1] = i / 2 + 1;
|
wr[i + 1] = i / 2 + 1;
|
||||||
|
|
Loading…
Reference in New Issue