diff options
Diffstat (limited to 'core/io/stream_peer.cpp')
-rw-r--r-- | core/io/stream_peer.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index e6175e78da..403f61bb24 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -34,8 +34,9 @@ Error StreamPeer::_put_data(const Vector<uint8_t> &p_data) { int len = p_data.size(); - if (len == 0) + if (len == 0) { return OK; + } const uint8_t *r = p_data.ptr(); return put_data(&r[0], len); } @@ -318,8 +319,9 @@ double StreamPeer::get_double() { } String StreamPeer::get_string(int p_bytes) { - if (p_bytes < 0) + if (p_bytes < 0) { p_bytes = get_u32(); + } ERR_FAIL_COND_V(p_bytes < 0, String()); Vector<char> buf; @@ -332,8 +334,9 @@ String StreamPeer::get_string(int p_bytes) { } String StreamPeer::get_utf8_string(int p_bytes) { - if (p_bytes < 0) + if (p_bytes < 0) { p_bytes = get_u32(); + } ERR_FAIL_COND_V(p_bytes < 0, String()); Vector<uint8_t> buf; @@ -421,8 +424,9 @@ void StreamPeerBuffer::_bind_methods() { } Error StreamPeerBuffer::put_data(const uint8_t *p_data, int p_bytes) { - if (p_bytes <= 0) + if (p_bytes <= 0) { return OK; + } if (pointer + p_bytes > data.size()) { data.resize(pointer + p_bytes); @@ -443,8 +447,9 @@ Error StreamPeerBuffer::put_partial_data(const uint8_t *p_data, int p_bytes, int Error StreamPeerBuffer::get_data(uint8_t *p_buffer, int p_bytes) { int recv; get_partial_data(p_buffer, p_bytes, recv); - if (recv != p_bytes) + if (recv != p_bytes) { return ERR_INVALID_PARAMETER; + } return OK; } |