diff options
author | Josh Rickmar <jrick@conformal.com> | 2013-06-06 10:23:54 -0400 |
---|---|---|
committer | Josh Rickmar <jrick@conformal.com> | 2013-06-06 11:14:39 -0400 |
commit | 3ae1aab215f8c40299ef82188c1f06e02f3a2abd (patch) | |
tree | 53f6ff7c9f5900ac579209cf109f70b6ce6cc719 | |
parent | eb8920525d11b2f6735f019c3ca4ee0afcea73ef (diff) | |
download | xombrero-3ae1aab215f8c40299ef82188c1f06e02f3a2abd.tar.gz |
Make string copies for basename calls
Linux basename(), unlike OpenBSD, takes a char * and may modify the contents of the path. We're previously were passing in internal webkit data so we must make a copy of it first.
-rw-r--r-- | about.c | 6 | ||||
-rw-r--r-- | xombrero.c | 17 |
2 files changed, 18 insertions, 5 deletions
diff --git a/about.c b/about.c index 46d0918..fdab608 100644 --- a/about.c +++ b/about.c @@ -1396,6 +1396,7 @@ xtp_page_dl_row(struct tab *t, char *html, struct download *dl) WebKitDownloadStatus stat; const gchar *destination; + gchar *d; char *status_html = NULL, *cmd_html = NULL, *new_html; gdouble progress; char cur_sz[FMT_SCALED_STRSIZE]; @@ -1472,11 +1473,12 @@ xtp_page_dl_row(struct tab *t, char *html, struct download *dl) /* we might not have a destination set yet */ if (!destination) destination = webkit_download_get_suggested_filename(dl->download); + d = g_strdup(destination); /* copy for basename */ new_html = g_strdup_printf( "%s\n<tr><td>%s</td><td>%s</td>" "<td style='text-align:center'>%s</td></tr>\n", - html, basename((char *)destination), - status_html, cmd_html); + html, basename(d), status_html, cmd_html); + g_free(d); g_free(html); if (status_html) diff --git a/xombrero.c b/xombrero.c index 18cc4c8..5561778 100644 --- a/xombrero.c +++ b/xombrero.c @@ -5118,6 +5118,7 @@ download_status_changed_cb(WebKitDownload *download, GParamSpec *spec, const char *uri; char *file = NULL; char *mime = NULL; + char *destination; if (download == NULL) return; @@ -5125,9 +5126,14 @@ download_status_changed_cb(WebKitDownload *download, GParamSpec *spec, if (status != WEBKIT_DOWNLOAD_STATUS_FINISHED) return; - if (download_notifications) + if (download_notifications) { + /* because basename() takes a char * on linux */ + destination = g_strdup( + webkit_download_get_destination_uri(download)); show_oops(NULL, "Download of '%s' finished", - basename(webkit_download_get_destination_uri(download))); + basename(destination)); + g_free(destination); + } uri = webkit_download_get_destination_uri(download); if (uri == NULL) return; @@ -5185,6 +5191,7 @@ download_start(struct tab *t, struct download *d, int flag) gchar *filename = NULL; char *uri = NULL; char *path = NULL; + char *destination; int ret = TRUE; int i; @@ -5254,8 +5261,12 @@ download_start(struct tab *t, struct download *d, int flag) /* get from history */ g_object_ref(d->download); + /* because basename() takes a char * on linux */ + destination = g_strdup( + webkit_download_get_destination_uri(d->download)); show_oops(t, "Download of '%s' started...", - basename(webkit_download_get_destination_uri(d->download))); + basename(destination)); + g_free(destination); } if (flag != XT_DL_START) |