Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential memory leak on edge cases inside AddFormData() #688

Closed
Dmitry-Me opened this issue Feb 29, 2016 · 2 comments
Closed

Potential memory leak on edge cases inside AddFormData() #688

Dmitry-Me opened this issue Feb 29, 2016 · 2 comments

Comments

@Dmitry-Me
Copy link

Cppcheck highlighted this code. lib\formdata.c contains this code with two early returns either of which results in having memory pointed to my newform leaked.

  static CURLcode AddFormData( PARAMS HERE)
 {
     struct FormData *newform = malloc(sizeof(struct FormData));
    if(!newform)
         return CURLE_OUT_OF_MEMORY;
    newform->next = NULL;

   if(length < 0 || (size && *size < 0))
        /* MEMORY LEAK - newform is not freed */
        return CURLE_BAD_FUNCTION_ARGUMENT;

  if(type <= FORM_CONTENT) {
    if(!length)
       /*WHATEVER*/
    else if(length >= (curl_off_t)(size_t)-1)
      /* MEMORY LEAK - newform is not freed */
       return CURLE_BAD_FUNCTION_ARGUMENT;
@bagder
Copy link
Member

bagder commented Feb 29, 2016

Yeps, seems like legitimate complaints...

@bagder bagder closed this as completed in c2a809c Feb 29, 2016
@bagder
Copy link
Member

bagder commented Feb 29, 2016

thanks!

@lock lock bot locked as resolved and limited conversation to collaborators May 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants