Skip to content

Commit

Permalink
uORBManager.hpp: Check handle validity in queue/dequeueCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
pussuw committed Oct 9, 2023
1 parent 4c22f26 commit ed48854
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions platforms/common/uORB/uORBManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,22 @@ class Manager

static void queueCallback(class SubscriptionCallback *sub, int idx)
{
_Instance->g_sem_pool.cb_lock(idx);
_Instance->g_sem_pool.cb_set(idx, sub);
// The manager is unlocked in callback thread
if (idx >= 0) {
_Instance->g_sem_pool.cb_lock(idx);
_Instance->g_sem_pool.cb_set(idx, sub);
// The manager is unlocked in callback thread
}
}

static class SubscriptionCallback *dequeueCallback(int idx)
{
class SubscriptionCallback *sub = _Instance->g_sem_pool.cb_get(idx);
_Instance->g_sem_pool.cb_unlock(idx);
class SubscriptionCallback *sub = nullptr;

if (idx >= 0) {
sub = _Instance->g_sem_pool.cb_get(idx);
_Instance->g_sem_pool.cb_unlock(idx);
}

return sub;
}

Expand Down

0 comments on commit ed48854

Please sign in to comment.