diff options
author | Leonardo Taccari <iamleot@gmail.com> | 2018-10-25 13:55:21 +0200 |
---|---|---|
committer | Leonardo Taccari <iamleot@gmail.com> | 2018-10-25 13:55:21 +0200 |
commit | bcaeed1773462e4abcae4e480839ef52f622fefc (patch) | |
tree | 1cd4db2dc5ceaba7fefae7c9c44dc5f550baf60c | |
parent | 0ed72711716b9fe08b6e6613cc33bddbd400e0be (diff) |
Always pass NUL-terminated text to command_spawn_editor()
It seems that there is no any guarantee that
webkit_web_resource_get_data_finish() return data that is
NUL-terminated.
-rw-r--r-- | src/normal.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/normal.c b/src/normal.c index 689bf1b..4044409 100644 --- a/src/normal.c +++ b/src/normal.c @@ -760,10 +760,13 @@ static void normal_view_source_loaded(WebKitWebResource *resource, GAsyncResult *res, Client *c) { gsize length; - guchar *text = NULL; + guchar *data = NULL; + char *text = NULL; - text = webkit_web_resource_get_data_finish(resource, res, &length, NULL); + data = webkit_web_resource_get_data_finish(resource, res, &length, NULL); + text = g_strndup(data, length); command_spawn_editor(c, &((Arg){0, (char *)text}), NULL, NULL); + g_free(data); g_free(text); } |