[epiphany] Remove unnecessary allocation in web_resource_data_cb
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Remove unnecessary allocation in web_resource_data_cb
- Date: Tue, 7 Jan 2020 18:43:42 +0000 (UTC)
commit 604f9c8f38d0cdbfba26ca92f9a981baca420f7c
Author: Jan-Michael Brummer <jan brummer tabos org>
Date: Sat Jan 4 00:04:32 2020 +0100
Remove unnecessary allocation in web_resource_data_cb
... also removes buggy clang static analyzer warning.
embed/ephy-view-source-handler.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/embed/ephy-view-source-handler.c b/embed/ephy-view-source-handler.c
index 761cf95f0..937690079 100644
--- a/embed/ephy-view-source-handler.c
+++ b/embed/ephy-view-source-handler.c
@@ -109,23 +109,19 @@ web_resource_data_cb (WebKitWebResource *resource,
EphyViewSourceRequest *request)
{
g_autofree guchar *data = NULL;
- g_autofree char *data_str = NULL;
g_autofree char *escaped_str = NULL;
g_autoptr (GError) error = NULL;
g_autofree char *html = NULL;
gsize length;
data = webkit_web_resource_get_data_finish (resource, result, &length, &error);
- if (error) {
+ if (!data) {
finish_uri_scheme_request (request, NULL, error);
return;
}
- data_str = g_malloc (length + 1);
- strncpy (data_str, (const char *)data, length);
- data_str[length] = '\0';
-
- escaped_str = g_markup_escape_text (data_str, -1);
+ /* Warning: We expect 'data' to be a nul terminated string, but it is not mandatory */
+ escaped_str = g_markup_escape_text ((const char *)data, length);
html = g_strdup_printf ("<head>"
" <link rel='stylesheet'
href='ephy-resource:///org/gnome/epiphany/highlight.css'>"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]