Don't leak internal file on error if mpw_marshal_write file is NULL.
This commit is contained in:
parent
b118bc4e9b
commit
24a6781687
@ -695,11 +695,17 @@ const char *mpw_marshal_write(
|
|||||||
if (!file)
|
if (!file)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!file->data) {
|
if (!file->data) {
|
||||||
file->error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate data." };
|
if (!file_)
|
||||||
|
mpw_marshal_file_free( &file );
|
||||||
|
else
|
||||||
|
file->error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate data." };
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!user->fullName || !strlen( user->fullName )) {
|
if (!user->fullName || !strlen( user->fullName )) {
|
||||||
file->error = (MPMarshalError){ MPMarshalErrorMissing, "Missing full name." };
|
if (!file_)
|
||||||
|
mpw_marshal_file_free( &file );
|
||||||
|
else
|
||||||
|
file->error = (MPMarshalError){ MPMarshalErrorMissing, "Missing full name." };
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
file->error = (MPMarshalError){ MPMarshalSuccess, NULL };
|
file->error = (MPMarshalError){ MPMarshalSuccess, NULL };
|
||||||
@ -740,7 +746,10 @@ const char *mpw_marshal_write(
|
|||||||
// Clear Text
|
// Clear Text
|
||||||
mpw_free( &masterKey, MPMasterKeySize );
|
mpw_free( &masterKey, MPMasterKeySize );
|
||||||
if (!user->masterKeyProvider || !(masterKey = user->masterKeyProvider( site->algorithm, user->fullName ))) {
|
if (!user->masterKeyProvider || !(masterKey = user->masterKeyProvider( site->algorithm, user->fullName ))) {
|
||||||
file->error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't derive master key." };
|
if (!file_)
|
||||||
|
mpw_marshal_file_free( &file );
|
||||||
|
else
|
||||||
|
file->error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't derive master key." };
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user