diff --git a/src/heap-inl.h b/src/heap-inl.h index 1e2ed60e09417c481f07a51c59d9866baa7ebe81..e3de2a7056d6509157d7730de8daa54854a1c48b 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -17,6 +17,7 @@ #define UV_SRC_HEAP_H_ #include /* NULL */ +#include "uv_log.h" #if defined(__GNUC__) # define HEAP_EXPORT(declaration) __attribute__((unused)) static declaration @@ -178,12 +179,18 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, k -= 1; } - heap->nelts -= 1; - /* Unlink the max node. */ child = *max; *max = NULL; +#ifdef USE_OHOS_DFX + if (child == NULL) { + UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); + return; + } +#endif + heap->nelts -= 1; + if (child == node) { /* We're removing either the max or the last node in the tree. */ if (child == heap->min) {