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