diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-04-02 22:55:52 +0200 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-04-02 22:56:17 +0200 |
commit | 0338e55a6ebaed0b2116c8dde6c5ec56b8774f6d (patch) | |
tree | e67f2e3d21b842c97f3edb4da48ae597d9c62ffc | |
parent | 25c1363a1167cc5833111e78e33b2561f1ceb76c (diff) |
Fix memory leak introduced in bb6814a
-rw-r--r-- | modules/mono/glue/arguments_vector.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/mono/glue/arguments_vector.h b/modules/mono/glue/arguments_vector.h index cb558235d8..8c0f308c15 100644 --- a/modules/mono/glue/arguments_vector.h +++ b/modules/mono/glue/arguments_vector.h @@ -39,6 +39,7 @@ struct ArgumentsVector { private: T pool[POOL_SIZE]; T *_ptr; + int size; ArgumentsVector(); ArgumentsVector(const ArgumentsVector &); @@ -48,11 +49,18 @@ public: T &get(int p_idx) { return _ptr[p_idx]; } void set(int p_idx, const T &p_value) { _ptr[p_idx] = p_value; } - explicit ArgumentsVector(int size) { - if (size <= POOL_SIZE) { + explicit ArgumentsVector(int p_size) : + size(p_size) { + if (p_size <= POOL_SIZE) { _ptr = pool; } else { - _ptr = memnew_arr(T, size); + _ptr = memnew_arr(T, p_size); + } + } + + ~ArgumentsVector() { + if (size > POOL_SIZE) { + memdelete_arr(_ptr); } } }; |