#831 cookie.c may leak memory

closed-fixed
libcurl (354)
5
2013-06-21
2009-05-25
T. Manske
No

version 7.19.5, 7.19.4

Valgrind hinted me to memory leaks in lib/cookie.c with my application.
The appended patch stuffed them for me.

Discussion

  • T. Manske
    T. Manske
    2009-05-25

    Patch for lib/cookie.c

     
    Attachments
  • oh, do you by any chance receive cookies with multiple domain and path properties? Or how did you end up with a leak for these?

     
  • cookie leak fix with strstore()

     
    Attachments
  • Assuming that was the case, can you give me your opinion on my suggested fix for this as I just attached here?

     
  • T. Manske
    T. Manske
    2009-05-25

    Well, the cookies are set manually so they may not be well formed. Ii.e. they come from javascript, not http, so they may not be well formed. My application just passes them to libcurl without validation. Indeed there are sometimes doubled path and/or domain parts in them.

     
  • T. Manske
    T. Manske
    2009-05-25

    Thanks, this helps as well.
    I suggest changing the type of the second argument of strstore() to const char * to get rid of those compiler warnings.

     
  • Thanks, I did that and committed this fix just now. If you tell me your full name I'll give you the proper credit for this find in the changelog etc.

     
    • status: open --> open-fixed
     
    • status: open-fixed --> closed-fixed