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>
这个提交包含在:
Sunday Clement 编写, Clement, Sunday 于 2025-05-30 09:16:26 -04:00 提交
1 父节点 fc561ff37a
当前提交 293092f32f
1 个文件已更改
+3 -3
@@ -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) {