diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-03-13 21:55:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-13 21:55:52 +0100 |
commit | 7015027cbf6ee071198267b6f4ffc3f4e40dfdd5 (patch) | |
tree | ee57d4cc0caa3fb4dfca2f1a76d69de8b2070d9e /modules | |
parent | 0e3aae00d88848f9e840f940959f2ecd05ed7a8a (diff) | |
parent | 838e7d0a8d49ac5d2d149acf7afc6b909f640485 (diff) |
Merge pull request #46900 from Ev1lbl0w/bugfix-malloc_calls
Replace malloc's with Godot's memalloc macro
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mono/mono_gd/support/android_support.cpp | 4 | ||||
-rw-r--r-- | modules/xatlas_unwrap/register_types.cpp | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/modules/mono/mono_gd/support/android_support.cpp b/modules/mono/mono_gd/support/android_support.cpp index cba29d63cd..5dd33b036a 100644 --- a/modules/mono/mono_gd/support/android_support.cpp +++ b/modules/mono/mono_gd/support/android_support.cpp @@ -415,8 +415,7 @@ GD_PINVOKE_EXPORT int32_t monodroid_get_system_property(const char *p_name, char if (r_value) { if (len >= 0) { *r_value = (char *)malloc(len + 1); - if (!*r_value) - return -1; + ERR_FAIL_NULL_V_MSG(*r_value, -1, "Out of memory."); memcpy(*r_value, prop_value_str, len); (*r_value)[len] = '\0'; } else { @@ -637,6 +636,7 @@ GD_PINVOKE_EXPORT int32_t _monodroid_get_dns_servers(void **r_dns_servers_array) if (dns_servers_count > 0) { size_t ret_size = sizeof(char *) * (size_t)dns_servers_count; *r_dns_servers_array = malloc(ret_size); // freed by the BCL + ERR_FAIL_NULL_MSG(*r_dns_servers_array, "Out of memory."); memcpy(*r_dns_servers_array, dns_servers, ret_size); } diff --git a/modules/xatlas_unwrap/register_types.cpp b/modules/xatlas_unwrap/register_types.cpp index fb4df10904..e1f9521a48 100644 --- a/modules/xatlas_unwrap/register_types.cpp +++ b/modules/xatlas_unwrap/register_types.cpp @@ -161,8 +161,11 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver const xatlas::Mesh &output = atlas->meshes[0]; *r_vertices = (int *)malloc(sizeof(int) * output.vertexCount); + ERR_FAIL_NULL_V_MSG(*r_vertices, false, "Out of memory."); *r_uvs = (float *)malloc(sizeof(float) * output.vertexCount * 2); + ERR_FAIL_NULL_V_MSG(*r_uvs, false, "Out of memory."); *r_indices = (int *)malloc(sizeof(int) * output.indexCount); + ERR_FAIL_NULL_V_MSG(*r_indices, false, "Out of memory."); float max_x = 0.0; float max_y = 0.0; |