Skip to content

Crashed at Curl_http_bodysend #12410

@yushicheng7788

Description

@yushicheng7788

I did this

I use CURLOPT_HTTPPOST to send files, but curl crashed. I think it is caused by the following part of the code.

/* Convert the form structure into a mime structure, then keep
       the conversion */
    if(!data->state.formp) {
      data->state.formp = calloc(sizeof(curl_mimepart), 1);
      if(!data->state.formp)
        return CURLE_OUT_OF_MEMORY;
      Curl_mime_cleanpart(data->state.formp);
      result = Curl_getformdata(data, data->state.formp, data->set.httppost,
                                data->state.fread_func, data->state.seek_func);
      if(result)
        return result;
      data->state.mimepost = data->state.formp;
    }

If Curl_getformdata() returns any error, which will cause data->state.mimepost = data->state.formp; not executed. But if I sent this request again, data->state.formp is not NULL, and data->state.mimepost is NULL, which cause a crash. Is there any optimization method in this case?

I expected the following

Curl will not crash in this case.

curl/libcurl version

8.4.0

operating system

MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions