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

Comments

Projects
None yet
2 participants
@Dmitry-Me

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 bagder added the memory-leak label Feb 29, 2016

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Feb 29, 2016

Member

Yeps, seems like legitimate complaints...

Member

bagder commented Feb 29, 2016

Yeps, seems like legitimate complaints...

@bagder bagder closed this in c2a809c Feb 29, 2016

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Feb 29, 2016

Member

thanks!

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.