mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
curls?ftpsink: Fix memory leaks due to new error handling
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=732174
This commit is contained in:
parent
42b3d6ec8a
commit
96c78695f9
2 changed files with 14 additions and 19 deletions
|
@ -185,7 +185,6 @@ set_ftp_dynamic_options_unlocked (GstCurlBaseSink * basesink)
|
|||
gchar *rename_to = NULL;
|
||||
gchar *uploadfile_as = NULL;
|
||||
gchar *last_slash = NULL;
|
||||
gchar *dir_name = NULL;
|
||||
gchar *tmpfile_name = NULL;
|
||||
|
||||
if (sink->headerlist != NULL) {
|
||||
|
@ -204,57 +203,54 @@ set_ftp_dynamic_options_unlocked (GstCurlBaseSink * basesink)
|
|||
|
||||
last_slash = strrchr (basesink->file_name, '/');
|
||||
if (last_slash != NULL) {
|
||||
dir_name =
|
||||
gchar *dir_name =
|
||||
g_strndup (basesink->file_name, last_slash - basesink->file_name);
|
||||
rename_to = g_strdup_printf ("%s%s", RENAME_TO, last_slash + 1);
|
||||
uploadfile_as = g_strdup_printf ("%s/%s", dir_name, tmpfile_name);
|
||||
g_free (dir_name);
|
||||
} else {
|
||||
rename_to = g_strdup_printf ("%s%s", RENAME_TO, basesink->file_name);
|
||||
uploadfile_as = g_strdup_printf ("%s", tmpfile_name);
|
||||
}
|
||||
g_free (tmpfile_name);
|
||||
|
||||
tmp = g_strdup_printf ("%s%s", basesink->url, uploadfile_as);
|
||||
g_free (uploadfile_as);
|
||||
|
||||
sink->headerlist = curl_slist_append (sink->headerlist, rename_from);
|
||||
sink->headerlist = curl_slist_append (sink->headerlist, rename_to);
|
||||
g_free (rename_from);
|
||||
g_free (rename_to);
|
||||
|
||||
res = curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
|
||||
g_free (tmp);
|
||||
if (res != CURLE_OK) {
|
||||
g_free (tmp);
|
||||
basesink->error = g_strdup_printf ("failed to set URL: %s",
|
||||
curl_easy_strerror (res));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sink->headerlist = curl_slist_append (sink->headerlist, rename_from);
|
||||
sink->headerlist = curl_slist_append (sink->headerlist, rename_to);
|
||||
|
||||
res = curl_easy_setopt (basesink->curl, CURLOPT_POSTQUOTE, sink->headerlist);
|
||||
if (res != CURLE_OK) {
|
||||
g_free (tmp);
|
||||
basesink->error = g_strdup_printf ("failed to set post quote: %s",
|
||||
curl_easy_strerror (res));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_free (rename_from);
|
||||
g_free (rename_to);
|
||||
g_free (uploadfile_as);
|
||||
g_free (dir_name);
|
||||
g_free (tmpfile_name);
|
||||
if (last_slash != NULL) {
|
||||
*last_slash = '\0';
|
||||
}
|
||||
} else {
|
||||
tmp = g_strdup_printf ("%s%s", basesink->url, basesink->file_name);
|
||||
res = curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
|
||||
g_free (tmp);
|
||||
if (res != CURLE_OK) {
|
||||
g_free (tmp);
|
||||
basesink->error = g_strdup_printf ("failed to set URL: %s",
|
||||
curl_easy_strerror (res));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (tmp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,15 +140,14 @@ set_sftp_dynamic_options_unlocked (GstCurlBaseSink * basesink)
|
|||
gchar *tmp = g_strdup_printf ("%s%s", basesink->url, basesink->file_name);
|
||||
CURLcode curl_err = CURLE_OK;
|
||||
|
||||
if ((curl_err =
|
||||
curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp)) != CURLE_OK) {
|
||||
curl_err = curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
|
||||
g_free (tmp);
|
||||
if (curl_err != CURLE_OK) {
|
||||
basesink->error = g_strdup_printf ("failed to set URL: %s",
|
||||
curl_easy_strerror (curl_err));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_free (tmp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue