@@ -315,7 +315,7 @@ void *phpdbg_watchpoint_userfaultfd_thread(void *phpdbg_globals) {
315315
316316 struct uffd_msg fault_msg = {0 };
317317 while (read (globals -> watch_userfaultfd , & fault_msg , sizeof (fault_msg )) == sizeof (fault_msg )) {
318- void * page = phpdbg_get_page_boundary ((char * )(uintptr_t ) fault_msg .arg .pagefault .address );
318+ void * page = phpdbg_get_page_boundary ((char * )(uintptr_t ) fault_msg .arg .pagefault .address );
319319 zend_hash_index_add_empty_element (globals -> watchlist_mem , (zend_ulong ) page );
320320 struct uffdio_writeprotect unprotect = {
321321 .mode = 0 ,
@@ -668,7 +668,7 @@ void phpdbg_watch_parent_ht(phpdbg_watch_element *element) {
668668}
669669
670670void phpdbg_unwatch_parent_ht (phpdbg_watch_element * element ) {
671- if (element -> watch -> type == WATCH_ON_BUCKET ) {
671+ if (element -> watch && element -> watch -> type == WATCH_ON_BUCKET ) {
672672 phpdbg_btree_result * res = phpdbg_btree_find (& PHPDBG_G (watch_HashTables ), (zend_ulong ) element -> parent_container );
673673 ZEND_ASSERT (element -> parent_container );
674674 if (res ) {
@@ -969,11 +969,14 @@ void phpdbg_remove_watchpoint(phpdbg_watchpoint_t *watch) {
969969}
970970
971971void phpdbg_clean_watch_element (phpdbg_watch_element * element ) {
972- HashTable * elements = & element -> watch -> elements ;
973972 phpdbg_unwatch_parent_ht (element );
974- zend_hash_del (elements , element -> str );
975- if (zend_hash_num_elements (elements ) == 0 ) {
976- phpdbg_remove_watchpoint (element -> watch );
973+
974+ if (element -> watch ) {
975+ HashTable * elements = & element -> watch -> elements ;
976+ zend_hash_del (elements , element -> str );
977+ if (zend_hash_num_elements (elements ) == 0 ) {
978+ phpdbg_remove_watchpoint (element -> watch );
979+ }
977980 }
978981}
979982
0 commit comments