fix memory leak when initialize obj fail
This commit is contained in:
parent
7212ba170d
commit
53cf11e6df
1 changed files with 6 additions and 3 deletions
|
|
@ -42,14 +42,17 @@ var makeInstance(typeinfo_t* type, ...)
|
|||
obj = objAlloc(type, type->dataSize(ap1));
|
||||
va_end(ap1);
|
||||
|
||||
if (obj != NULL) {
|
||||
rc = type->init(obj, ap);
|
||||
if (obj == NULL) {
|
||||
va_end(ap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = type->init(obj, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
if (rc < 0) {
|
||||
destroy(obj);
|
||||
destroy(RTTI_OBJ_TO_DATA(void, obj));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue