Skip to content

Commit 11072bc

Browse files
committed
Fix crash in NewFromEncodedNodeTree when passing in zero length string
1 parent 1fe20ed commit 11072bc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CMakeList.txt : CMake project for FastNoise2
22
cmake_minimum_required(VERSION 3.7.1)
33

4-
project(FastNoise2 VERSION 0.9.6)
4+
project(FastNoise2 VERSION 0.9.7)
55
set(CMAKE_CXX_STANDARD 17)
66

77
message("FastNoise2 Arch: ${CMAKE_SYSTEM_PROCESSOR}")

src/FastNoise/Base64.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ namespace FastNoise
9999
};
100100

101101
size_t in_len = std::strlen( input );
102-
if( in_len % 4 != 0 ) return {};
103-
104102
size_t out_len = in_len / 4 * 3;
103+
104+
if( out_len == 0 || in_len % 4 != 0 ) return {};
105+
105106
if( input[in_len - 1] == '=' ) out_len--;
106107
if( input[in_len - 2] == '=' ) out_len--;
107108

0 commit comments

Comments
 (0)