curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: segfault when reuse curl_slist

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 8 May 2017 07:46:25 +0200 (CEST)

On Mon, 8 May 2017, Pahome Chen wrote:

> I thought the curl_slist_append will append headers to freed list. so it
> needs to points to NULL again if I want to reuse?

Please stop top-posting.

If you free the slist and then try to append headers to that freed list, you
will most likely get a crash or some other memory related problems, much in
the same way you can't work on memory you free()d already.

If you pass in a NULL pointer as the first argument to curl_slist_append, it
will create/malloc a new list to work on.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-05-08