summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/normal.c12
-rw-r--r--src/util.c4
2 files changed, 9 insertions, 7 deletions
diff --git a/src/normal.c b/src/normal.c
index 4044409..0efc0b1 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -751,7 +751,7 @@ static VbResult normal_view_source(Client *c, const NormalCmdInfo *info)
}
webkit_web_resource_get_data(resource, NULL,
- (GAsyncReadyCallback)normal_view_source_loaded, c);
+ (GAsyncReadyCallback)normal_view_source_loaded, c);
return RESULT_COMPLETE;
}
@@ -764,10 +764,12 @@ static void normal_view_source_loaded(WebKitWebResource *resource,
char *text = 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);
+ if (data) {
+ text = g_strndup(data, length);
+ command_spawn_editor(c, &((Arg){0, (char *)text}), NULL, NULL);
+ g_free(data);
+ g_free(text);
+ }
}
static VbResult normal_yank(Client *c, const NormalCmdInfo *info)
diff --git a/src/util.c b/src/util.c
index 0255e54..e22bb1d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -134,8 +134,8 @@ gboolean util_create_tmp_file(const char *content, char **file)
}
if (content == NULL) {
- close(fp);
- return TRUE;
+ close(fp);
+ return TRUE;
}
len = strlen(content);