summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-11-20 21:31:12 +0100
committerGitHub <noreply@github.com>2019-11-20 21:31:12 +0100
commit083d088de3fe7cd5d825cebebc46ce32fc87b4b0 (patch)
tree9b2524105bf989f6ac0ad1c488ac493f558a391f /core
parent719254ae0d4e1b7c9be36a4399809caf270d7e86 (diff)
parent99d8626f4a313471410db421891e90fe768cd929 (diff)
Merge pull request #33583 from qarmin/fix_overflows_unitialized
Fix some overflows and unitialized variables
Diffstat (limited to 'core')
-rw-r--r--core/io/packet_peer.cpp1
-rw-r--r--core/math/camera_matrix.cpp4
-rw-r--r--core/project_settings.cpp2
-rw-r--r--core/typedefs.h3
-rw-r--r--core/ustring.cpp2
5 files changed, 11 insertions, 1 deletions
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 821a04ebad..23dfc58385 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -279,6 +279,7 @@ Ref<StreamPeer> PacketPeerStream::get_stream_peer() const {
void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
+ ERR_FAIL_COND_MSG(p_max_size < 0, "Max size of input buffer size cannot be smaller than 0.");
//warning may lose packets
ERR_FAIL_COND_MSG(ring_buffer.data_left(), "Buffer in use, resizing would cause loss of data.");
ring_buffer.resize(nearest_shift(p_max_size + 4));
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 30c0cab909..b9b0f4ac54 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -183,6 +183,10 @@ void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear
void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far) {
+ ERR_FAIL_COND(p_right <= p_left);
+ ERR_FAIL_COND(p_top <= p_bottom);
+ ERR_FAIL_COND(p_far <= p_near);
+
real_t *te = &matrix[0][0];
real_t x = 2 * p_near / (p_right - p_left);
real_t y = 2 * p_near / (p_top - p_bottom);
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 7704c7b377..ba5cdd782f 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -525,6 +525,8 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) {
set(key, value);
}
+ f->close();
+ memdelete(f);
return OK;
}
diff --git a/core/typedefs.h b/core/typedefs.h
index 767a97ac38..42f34c73cb 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -174,6 +174,9 @@ inline void __swap_tmpl(T &x, T &y) {
static _FORCE_INLINE_ unsigned int next_power_of_2(unsigned int x) {
+ if (x == 0)
+ return 0;
+
--x;
x |= x >> 1;
x |= x >> 2;
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 0f82ca7e15..25930db201 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -1416,7 +1416,7 @@ bool String::parse_utf8(const char *p_utf8, int p_len) {
if (skip == 0) {
- uint8_t c = *ptrtmp;
+ uint8_t c = *ptrtmp >= 0 ? *ptrtmp : uint8_t(256 + *ptrtmp);
/* Determine the number of characters in sequence */
if ((c & 0x80) == 0)