# [PATCH] fix zend_llist_remove_tail

- Thread: https://externals.io/message/27692
- Original archive: https://news-web.php.net/php.internals/27692
- Started by Michael Wallner on 2007-01-27T17:32:54+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #27692 — Michael Wallner — 2007-01-27T17:32:54+00:00

URL: https://externals.io/message/27692#27692

The attached patch fixes zend_llist_remove_tail() which didn't reset zend_llist->head properly.
The diff was generated against 5_2.

Regards,
-- 
Michael

---

## #27728 — Michael Wallner — 2007-02-02T17:19:08+00:00

URL: https://externals.io/message/27692#27728 · In reply to: #27692

*If* anybody's wondering... I don't have karma.

Michael Wallner wrote:
> The attached patch fixes zend_llist_remove_tail() which didn't reset zend_llist->head properly.
> The diff was generated against 5_2.
> 
> Regards,
> 
> 
> ------------------------------------------------------------------------
> 
> Index: Zend/zend_llist.c
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_llist.c,v
> retrieving revision 1.35.2.1.2.1
> diff -u -p -d -r1.35.2.1.2.1 zend_llist.c
> --- Zend/zend_llist.c	1 Jan 2007 09:35:46 -0000	1.35.2.1.2.1
> +++ Zend/zend_llist.c	27 Jan 2007 17:31:36 -0000
> @@ -130,28 +130,17 @@ ZEND_API void zend_llist_clean(zend_llis
>  
>  ZEND_API void *zend_llist_remove_tail(zend_llist *l)
>  {
> -	zend_llist_element *old_tail;
> +	zend_llist_element *current = l->tail;
>  	void *data;
> -
> -	if ((old_tail = l->tail)) {
> -		if (l->tail->prev) {
> -			l->tail->prev->next = NULL;
> -		}
> -        
> -		data = old_tail->data;
> -
> -		l->tail = l->tail->prev;
> -		if (l->dtor) {
> -			l->dtor(data);
> -		}
> -		pefree(old_tail, l->persistent);
> -
> -		--l->count;
> -
> -		return data;
> +	
> +	if (current) {
> +		data = current->data;
> +		DEL_LLIST_ELEMENT(current, l);
> +	} else {
> +		data = NULL;
>  	}
> -
> -	return NULL;
> +	
> +	return data;
>  }
>  
>  


-- 
Michael
