Skip to content

Commit 9449fca

Browse files
committed
Memory leak error fixes. Various compiler fixes.
1 parent 759d6fc commit 9449fca

File tree

7 files changed

+16
-9
lines changed

7 files changed

+16
-9
lines changed

include/chaiscript/dispatchkit/bad_boxed_cast.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace chaiscript
4646
}
4747

4848
bad_boxed_cast(const bad_boxed_cast &) = default;
49-
virtual ~bad_boxed_cast() CHAISCRIPT_NOEXCEPT = default;
49+
virtual ~bad_boxed_cast() CHAISCRIPT_NOEXCEPT {}
5050

5151
/// \brief Description of what error occurred
5252
virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE

include/chaiscript/dispatchkit/proxy_functions.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ namespace chaiscript
224224
{
225225
}
226226

227-
virtual ~Dynamic_Proxy_Function() = default;
227+
virtual ~Dynamic_Proxy_Function() {}
228228

229229
virtual bool operator==(const Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE
230230
{
@@ -591,7 +591,7 @@ namespace chaiscript
591591
}
592592

593593
dispatch_error(const dispatch_error &) = default;
594-
virtual ~dispatch_error() CHAISCRIPT_NOEXCEPT = default;
594+
virtual ~dispatch_error() CHAISCRIPT_NOEXCEPT {}
595595

596596
std::vector<Boxed_Value> parameters;
597597
std::vector<Const_Proxy_Function> functions;

include/chaiscript/dispatchkit/type_conversions.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace chaiscript
4646

4747
bad_boxed_dynamic_cast(const bad_boxed_dynamic_cast &) = default;
4848

49-
virtual ~bad_boxed_dynamic_cast() CHAISCRIPT_NOEXCEPT = default;
49+
virtual ~bad_boxed_dynamic_cast() CHAISCRIPT_NOEXCEPT {}
5050
};
5151

5252
class bad_boxed_type_cast : public bad_boxed_cast
@@ -70,7 +70,7 @@ namespace chaiscript
7070

7171
bad_boxed_type_cast(const bad_boxed_type_cast &) = default;
7272

73-
virtual ~bad_boxed_type_cast() CHAISCRIPT_NOEXCEPT = default;
73+
virtual ~bad_boxed_type_cast() CHAISCRIPT_NOEXCEPT {}
7474
};
7575
}
7676

include/chaiscript/language/chaiscript_common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ namespace chaiscript
398398
{ }
399399

400400
file_not_found_error(const file_not_found_error &) = default;
401-
virtual ~file_not_found_error() CHAISCRIPT_NOEXCEPT = default;
401+
virtual ~file_not_found_error() CHAISCRIPT_NOEXCEPT {}
402402
};
403403

404404
}

include/chaiscript/language/chaiscript_engine.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace chaiscript
6262
}
6363

6464
load_module_error(const load_module_error &) = default;
65-
virtual ~load_module_error() CHAISCRIPT_NOEXCEPT = default;
65+
virtual ~load_module_error() CHAISCRIPT_NOEXCEPT {}
6666
};
6767
}
6868

src/test_module.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TestBaseType
99
public:
1010
TestBaseType() : val(10), const_val(15) { }
1111
TestBaseType(int) : val(10), const_val(15) {}
12-
TestBaseType(int *) : val(10), const_val(15) {}
12+
TestBaseType(int *i) : val(10), const_val(15) { }
1313
TestBaseType(const TestBaseType &) = default;
1414
virtual ~TestBaseType() {}
1515
virtual int func() { return 0; }
@@ -100,9 +100,11 @@ std::string hello_world()
100100
return "Hello World";
101101
}
102102

103+
int global_i = 1;
104+
103105
int *get_new_int()
104106
{
105-
return new int(1);
107+
return &global_i;
106108
}
107109

108110
// MSVC doesn't like that we are using C++ return types from our C declared module

unittests/boxed_cast_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,20 +265,25 @@ bool pointer_test(const T& default_value, const T& new_value)
265265

266266
if (p != (*result) ) {
267267
std::cerr << "Pointer passed in different than one returned\n";
268+
delete p;
268269
return false;
269270
}
270271

271272
if (*p != *(*result) ) {
272273
std::cerr << "Somehow dereferenced pointer values are not the same?\n";
274+
delete p;
273275
return false;
274276
}
275277

278+
delete p;
276279
return true;
277280
} catch (const exception::bad_boxed_cast &) {
278281
std::cerr << "Bad boxed cast performing ** to ** test\n";
282+
delete p;
279283
return false;
280284
} catch (...) {
281285
std::cerr << "Unknown exception performing ** to ** test\n";
286+
delete p;
282287
return false;
283288
}
284289

0 commit comments

Comments
 (0)