BAN: RefCounted<> frees count if object allocation fails

This commit is contained in:
Bananymous 2023-03-06 13:17:04 +02:00
parent d5f302a68b
commit e480f9c195
1 changed files with 3 additions and 0 deletions

View File

@ -84,7 +84,10 @@ namespace BAN
return Error::from_errno(ENOMEM);
T* data = new T(forward<Args>(args)...);
if (!data)
{
delete count;
return Error::from_errno(ENOMEM);
}
return RefCounted<T>(data, count);
}