Fixes bugs found by Sonarcloud and Coverity

This commit is contained in:
qarmin 2020-03-02 19:17:20 +01:00
parent 0c22f5a447
commit 1f209bfc41
10 changed files with 25 additions and 13 deletions

View file

@ -1008,7 +1008,9 @@ String ResourceLoaderBinary::recognize(FileAccess *p_f) {
ResourceLoaderBinary::ResourceLoaderBinary() :
translation_remapped(false),
ver_format(0),
f(NULL),
importmd_ofs(0),
error(OK) {
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) {
*r_error = err;
}
thread_load_mutex->unlock();
return RES();
}
thread_load_mutex->unlock();

View file

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

View file

@ -268,7 +268,10 @@ void MessageQueue::flush() {
//using reverse locking strategy
_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;
while (read_pos < buffer_end) {

View file

@ -77,7 +77,7 @@ public:
struct ResourceParser {
void *userdata;
void *userdata = nullptr;
ParseResourceFunc func;
ParseResourceFunc ext_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.pPoolSizes = sizes.ptr();
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);
}

View file

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

View file

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

View file

@ -1077,7 +1077,7 @@ RasterizerEffectsRD::~RasterizerEffectsRD() {
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);
}

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++) {
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]);
s->blend_shapes.push_back(vertex_buffer);
}