Skip to content

Commit d5e73a7

Browse files
committed
avoid double deletes
1 parent 9d637d7 commit d5e73a7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Common/include/option_structure.inl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,10 @@ struct CStringValuesListHelper {
10621062
template <class T>
10631063
struct CStringValuesListHelper<T*> {
10641064
static T* resize(unsigned short n) { return new T[n]; }
1065-
static void clear(T* ptr) { delete[] ptr; }
1065+
static void clear(T*& ptr) {
1066+
delete[] ptr;
1067+
ptr = nullptr;
1068+
}
10661069
static T& access(T* ptr, unsigned short i) { return ptr[i]; }
10671070
};
10681071

@@ -1092,6 +1095,8 @@ public:
10921095
}
10931096
delete[] values;
10941097
delete[] strings;
1098+
values = nullptr;
1099+
strings = nullptr;
10951100
};
10961101

10971102
string SetValue(vector<string> option_value) override {

0 commit comments

Comments
 (0)