Use the Type() ctor and avoid:

- clang warning about memset overwrite of vtable
  - memory leak
  - Undefined behavior in Type copy/move operations and dtor.
This commit is contained in:
Mike Romberg 2017-07-01 17:58:59 -06:00
commit 6c0885ff67

View file

@ -134,13 +134,12 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) calloc(1, sizeof(Type)); // memory leak?
static Type v_def;
if (!PyErr_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
return *v_def;
return v_def;
}
}
};