mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-05 17:32:54 +03:00
coap_threadsafe.c: Fix NPE in coap_delete_resource()
This commit is contained in:
1 parent
c162187a6a
commit
e7105286f6
3 files changed
+18
-6
No files matched your search
@@ -337,7 +337,7 @@ int coap_lock_lock_func(coap_lock_t *lock);
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define coap_lock_check_locked(s)
|
||||
#define coap_lock_check_locked(s) {}
|
||||
|
||||
# endif /* ! COAP_THREAD_RECURSIVE_CHECK */
|
||||
|
||||
@@ -352,7 +352,7 @@ typedef coap_mutex_t coap_lock_t;
|
||||
#define coap_lock_unlock(s)
|
||||
#define coap_lock_init(s)
|
||||
#define coap_lock_being_freed(s,failed)
|
||||
#define coap_lock_check_locked(s)
|
||||
#define coap_lock_check_locked(s) {}
|
||||
#define coap_lock_callback(s,func) func
|
||||
#define coap_lock_callback_ret(r,s,func) ret = func
|
||||
#define coap_lock_invert(s,func,f) func
|
||||
|
||||
+3
-1
@@ -555,8 +555,10 @@ coap_delete_resource(coap_context_t *context, coap_resource_t *resource) {
|
||||
if (!resource)
|
||||
return 0;
|
||||
|
||||
coap_lock_check_locked(context);
|
||||
context = resource->context;
|
||||
if (context) {
|
||||
coap_lock_check_locked(context);
|
||||
}
|
||||
|
||||
if (resource->is_unknown) {
|
||||
if (context && context->unknown_resource == resource) {
|
||||
|
||||
+13
-3
@@ -294,9 +294,17 @@ int
|
||||
coap_delete_resource(coap_context_t *context, coap_resource_t *resource) {
|
||||
int ret;
|
||||
|
||||
coap_lock_lock(context, return 0);
|
||||
ret = coap_delete_resource_locked(context, resource);
|
||||
coap_lock_unlock(context);
|
||||
if (!resource)
|
||||
return 0;
|
||||
|
||||
context = resource->context;
|
||||
if (context) {
|
||||
coap_lock_lock(context, return 0);
|
||||
ret = coap_delete_resource_locked(context, resource);
|
||||
coap_lock_unlock(context);
|
||||
} else {
|
||||
ret = coap_delete_resource_locked(context, resource);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -485,6 +493,8 @@ coap_delete_oscore_recipient(coap_context_t *context,
|
||||
coap_bin_const_t *recipient_id) {
|
||||
int ret;
|
||||
|
||||
if (!context || !recipient_id)
|
||||
return 0;
|
||||
coap_lock_lock(context, return 0);
|
||||
ret = coap_delete_oscore_recipient_locked(context, recipient_id);
|
||||
coap_lock_unlock(context);
|
||||
|
||||
Reference in new issue
Block a user