int body_size = 0;
int curr_len = 0;
size_t new_len = 0;
- gchar* ptr = NULL;
+ gchar *ptr = NULL;
+ char *tmp = NULL;
len = g_queue_get_length(request->body_queue);
if (len == 0) {
}
for (index = 0; index < len; index++) {
-
- ptr = (gchar*)g_queue_pop_head(request->body_queue);
+ ptr = (gchar *)g_queue_pop_head(request->body_queue);
if (!ptr) {
DBG("body_queue is empty\n");
break;
}
body_size = strlen(ptr);
-
new_len = curr_len + body_size;
- *body = realloc(*body, new_len + 1);
- if (*body == NULL) {
+
+ tmp = (char *)realloc(*body, new_len + 1);
+ if (tmp == NULL) {
DBG("realloc() failed\n");
return HTTP_ERROR_OUT_OF_MEMORY;
+ } else {
+ *body = tmp;
}
memcpy(*body + curr_len, ptr, body_size);
__http_transaction_h *transaction = (__http_transaction_h *)user_data;
__http_header_h *header = transaction->header;
- gchar *temp_header = NULL;
+ gchar *tmp = NULL;
size_t written = size * nmemb;
size_t new_len = header->rsp_header_len + written;
- temp_header = header->rsp_header;
- header->rsp_header = realloc(header->rsp_header, new_len + 1);
- if (header->rsp_header == NULL) {
- free(temp_header);
+ tmp = (gchar *)realloc(header->rsp_header, new_len + 1);
+ if (tmp == NULL) {
ERR("realloc() failed\n");
return -1;
+ } else {
+ header->rsp_header = tmp;
}
memcpy(header->rsp_header + header->rsp_header_len, buffer, written);
gchar *body = NULL;
ret = _read_request_body(transaction, &body);
- if (ret != HTTP_ERROR_NONE)
+ if (ret != HTTP_ERROR_NONE) {
+ g_free(body);
return ret;
+ }
if (body) {
curl_easy_setopt(transaction->easy_handle, CURLOPT_COPYPOSTFIELDS, body);