Merge pull request #36733 from qarmin/static_analyzer_fixes

Fixes bugs found by Sonarcloud and Coverity
This commit is contained in:
Rémi Verschelde 2020-03-04 13:41:38 +01:00 committed by GitHub
commit a0e33e17fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 25 additions and 13 deletions

View File

@ -1008,7 +1008,9 @@ String ResourceLoaderBinary::recognize(FileAccess *p_f) {
ResourceLoaderBinary::ResourceLoaderBinary() : ResourceLoaderBinary::ResourceLoaderBinary() :
translation_remapped(false), translation_remapped(false),
ver_format(0),
f(NULL), f(NULL),
importmd_ofs(0),
error(OK) { error(OK) {
progress = nullptr; progress = nullptr;

View File

@ -538,6 +538,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
if (r_error) { if (r_error) {
*r_error = err; *r_error = err;
} }
thread_load_mutex->unlock();
return RES(); return RES();
} }
thread_load_mutex->unlock(); thread_load_mutex->unlock();

View File

@ -116,7 +116,7 @@ private:
String type_hint; String type_hint;
float progress = 0.0; float progress = 0.0;
ThreadLoadStatus status = THREAD_LOAD_IN_PROGRESS; ThreadLoadStatus status = THREAD_LOAD_IN_PROGRESS;
Error error; Error error = OK;
RES resource; RES resource;
bool xl_remapped = false; bool xl_remapped = false;
bool use_sub_threads = false; bool use_sub_threads = false;

View File

@ -268,7 +268,10 @@ void MessageQueue::flush() {
//using reverse locking strategy //using reverse locking strategy
_THREAD_SAFE_LOCK_ _THREAD_SAFE_LOCK_
ERR_FAIL_COND(flushing); //already flushing, you did something odd if (flushing) {
_THREAD_SAFE_UNLOCK_
ERR_FAIL_COND(flushing); //already flushing, you did something odd
}
flushing = true; flushing = true;
while (read_pos < buffer_end) { while (read_pos < buffer_end) {

View File

@ -77,7 +77,7 @@ public:
struct ResourceParser { struct ResourceParser {
void *userdata; void *userdata = nullptr;
ParseResourceFunc func; ParseResourceFunc func;
ParseResourceFunc ext_func; ParseResourceFunc ext_func;
ParseResourceFunc sub_func; ParseResourceFunc sub_func;

View File

@ -4182,7 +4182,10 @@ RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_a
descriptor_pool_create_info.poolSizeCount = sizes.size(); descriptor_pool_create_info.poolSizeCount = sizes.size();
descriptor_pool_create_info.pPoolSizes = sizes.ptr(); descriptor_pool_create_info.pPoolSizes = sizes.ptr();
VkResult res = vkCreateDescriptorPool(device, &descriptor_pool_create_info, NULL, &pool->pool); VkResult res = vkCreateDescriptorPool(device, &descriptor_pool_create_info, NULL, &pool->pool);
ERR_FAIL_COND_V(res, NULL); if (res) {
memdelete(pool);
ERR_FAIL_COND_V(res, NULL);
}
descriptor_pools[p_key].insert(pool); descriptor_pools[p_key].insert(pool);
} }

View File

@ -403,8 +403,6 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
return Ref<PackedScene>(); return Ref<PackedScene>();
} }
} }
return packed_scene;
} }
Error ResourceLoaderText::load() { Error ResourceLoaderText::load() {
@ -671,10 +669,6 @@ Error ResourceLoaderText::load() {
return error; return error;
} }
} }
if (progress) {
*progress = resource_current / float(resources_total);
}
} }
//for scene files //for scene files
@ -731,9 +725,15 @@ void ResourceLoaderText::set_translation_remapped(bool p_remapped) {
} }
ResourceLoaderText::ResourceLoaderText() { ResourceLoaderText::ResourceLoaderText() {
resources_total = 0;
resource_current = 0;
use_sub_threads = false;
progress = nullptr; progress = nullptr;
lines = false;
translation_remapped = false; translation_remapped = false;
use_sub_threads = false; use_sub_threads = false;
error = OK;
} }
ResourceLoaderText::~ResourceLoaderText() { ResourceLoaderText::~ResourceLoaderText() {

View File

@ -1171,6 +1171,7 @@ public:
Command *n = c->next; Command *n = c->next;
if (c == commands) { if (c == commands) {
memdelete(commands); memdelete(commands);
commands = NULL;
} else { } else {
c->~Command(); c->~Command();
} }

View File

@ -1081,7 +1081,7 @@ RasterizerEffectsRD::~RasterizerEffectsRD() {
RD::get_singleton()->free(filter.image_uniform_set); RD::get_singleton()->free(filter.image_uniform_set);
} }
if (RD::get_singleton()->uniform_set_is_valid(filter.image_uniform_set)) { if (RD::get_singleton()->uniform_set_is_valid(filter.uniform_set)) {
RD::get_singleton()->free(filter.uniform_set); RD::get_singleton()->free(filter.uniform_set);
} }

View File

@ -1906,8 +1906,10 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_
for (int i = 0; i < p_surface.blend_shapes.size(); i++) { for (int i = 0; i < p_surface.blend_shapes.size(); i++) {
ERR_FAIL_COND(p_surface.blend_shapes[i].size() != p_surface.vertex_data.size()); if (p_surface.blend_shapes[i].size() != p_surface.vertex_data.size()) {
memdelete(s);
ERR_FAIL_COND(p_surface.blend_shapes[i].size() != p_surface.vertex_data.size());
}
RID vertex_buffer = RD::get_singleton()->vertex_buffer_create(p_surface.blend_shapes[i].size(), p_surface.blend_shapes[i]); RID vertex_buffer = RD::get_singleton()->vertex_buffer_create(p_surface.blend_shapes[i].size(), p_surface.blend_shapes[i]);
s->blend_shapes.push_back(vertex_buffer); s->blend_shapes.push_back(vertex_buffer);
} }