summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-03-04 13:41:38 +0100
committerGitHub <noreply@github.com>2020-03-04 13:41:38 +0100
commita0e33e17fbecc321d45306255814f9581504776c (patch)
tree966803124d47a23266ae3f81e57c7cf8f0456521
parentf83f1d7c9b299f21f818e0ea28c27345f65bde4b (diff)
parent1f209bfc41ef5f2cd63c961262d5d6fe3e03b55a (diff)
Merge pull request #36733 from qarmin/static_analyzer_fixes
Fixes bugs found by Sonarcloud and Coverity
-rw-r--r--core/io/resource_format_binary.cpp2
-rw-r--r--core/io/resource_loader.cpp1
-rw-r--r--core/io/resource_loader.h2
-rw-r--r--core/message_queue.cpp5
-rw-r--r--core/variant_parser.h2
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp5
-rw-r--r--scene/resources/resource_format_text.cpp12
-rw-r--r--servers/visual/rasterizer.h1
-rw-r--r--servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp2
-rw-r--r--servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp6
10 files changed, 25 insertions, 13 deletions
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 54b75cc29d..efd452191a 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -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;
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 504dbe2d63..5dca8b3b89 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -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();
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index 3b7a27f551..ea89917a5f 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -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;
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index 235003627e..37207483fe 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -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) {
diff --git a/core/variant_parser.h b/core/variant_parser.h
index ad0a4d6682..d50842145c 100644
--- a/core/variant_parser.h
+++ b/core/variant_parser.h
@@ -77,7 +77,7 @@ public:
struct ResourceParser {
- void *userdata;
+ void *userdata = nullptr;
ParseResourceFunc func;
ParseResourceFunc ext_func;
ParseResourceFunc sub_func;
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 8cea8ebb86..3b0d1f6ac3 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -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);
}
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index 97bd12c119..238bdf05ef 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -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() {
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 3a219ec7e3..0a55c78133 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -1171,6 +1171,7 @@ public:
Command *n = c->next;
if (c == commands) {
memdelete(commands);
+ commands = NULL;
} else {
c->~Command();
}
diff --git a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp
index 85750df9d1..6b6c750fd3 100644
--- a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp
+++ b/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp
@@ -1081,7 +1081,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);
}
diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp
index 15cbc61b76..52cefa7511 100644
--- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp
+++ b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp
@@ -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);
}