Commit bdf162af authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

formpost: trying to attach a directory no longer crashes

The error path would previously add a freed entry to the linked list.

Reported-by: Toby Peterson

Fixes #1053
parent 54e48b14
Loading
Loading
Loading
Loading
+8 −7
Original line number Original line Diff line number Diff line
@@ -863,13 +863,6 @@ static CURLcode AddFormData(struct FormData **formp,


  newform->type = type;
  newform->type = type;


  if(*formp) {
    (*formp)->next = newform;
    *formp = newform;
  }
  else
    *formp = newform;

  if(size) {
  if(size) {
    if(type != FORM_FILE)
    if(type != FORM_FILE)
      /* for static content as well as callback data we add the size given
      /* for static content as well as callback data we add the size given
@@ -889,6 +882,14 @@ static CURLcode AddFormData(struct FormData **formp,
      }
      }
    }
    }
  }
  }

  if(*formp) {
    (*formp)->next = newform;
    *formp = newform;
  }
  else
    *formp = newform;

  return CURLE_OK;
  return CURLE_OK;
  error:
  error:
  if(newform)
  if(newform)