rocr: Fix Resource Leak
allocated memory was previously not freed in the event of an error
with rwlock initialization.
Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>
[ROCm/ROCR-Runtime commit: 293092f32f]
This commit is contained in:
committed by
Clement, Sunday
parent
d2982b797a
commit
3d3cca8083
@@ -717,15 +717,15 @@ SharedMutex CreateSharedMutex() {
|
||||
}
|
||||
#endif
|
||||
|
||||
pthread_rwlock_t* lock = new pthread_rwlock_t;
|
||||
err = pthread_rwlock_init(lock, &attrib);
|
||||
std::unique_ptr<pthread_rwlock_t> lock(new pthread_rwlock_t);
|
||||
err = pthread_rwlock_init(lock.get(), &attrib);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "rw lock init failed: %s\n", strerror(err));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pthread_rwlockattr_destroy(&attrib);
|
||||
return lock;
|
||||
return lock.release();
|
||||
}
|
||||
|
||||
bool TryAcquireSharedMutex(SharedMutex lock) {
|
||||
|
||||
Reference in New Issue
Block a user