From 82a10e051c593e133554ce9675169fd68bb02ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 28 Jun 2015 22:22:42 +0200 Subject: Do not take address of variables which go out of scope This is a bit of a hack, since now the callers range is modified. The various cmd_* functions should probably take a const Filerange pointer as argument and modify a local Filerange variable if needed. --- vis.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index a6ad671..000a3ab 100644 --- a/vis.c +++ b/vis.c @@ -1573,7 +1573,7 @@ static bool cmd_read(Filerange *range, enum CmdOpt opt, const char *argv[]) { size_t pos = view_cursor_get(vis->win->view); if (!text_range_valid(range)) - range = &(Filerange){ .start = pos, .end = pos }; + *range = (Filerange){ .start = pos, .end = pos }; Filerange delete = *range; range->start = range->end; @@ -1586,7 +1586,7 @@ static bool cmd_read(Filerange *range, enum CmdOpt opt, const char *argv[]) { static bool cmd_substitute(Filerange *range, enum CmdOpt opt, const char *argv[]) { char pattern[255]; if (!text_range_valid(range)) - range = &(Filerange){ .start = 0, .end = text_size(vis->win->file->text) }; + *range = (Filerange){ .start = 0, .end = text_size(vis->win->file->text) }; snprintf(pattern, sizeof pattern, "s%s", argv[1]); return cmd_filter(range, opt, (const char*[]){ argv[0], "sed", pattern, NULL}); } @@ -1636,7 +1636,7 @@ static bool cmd_wq(Filerange *range, enum CmdOpt opt, const char *argv[]) { static bool cmd_write(Filerange *range, enum CmdOpt opt, const char *argv[]) { Text *text = vis->win->file->text; if (!text_range_valid(range)) - range = &(Filerange){ .start = 0, .end = text_size(text) }; + *range = (Filerange){ .start = 0, .end = text_size(text) }; if (!argv[1]) argv[1] = text_filename_get(text); if (!argv[1]) { @@ -1744,7 +1744,7 @@ static bool cmd_filter(Filerange *range, enum CmdOpt opt, const char *argv[]) { fcntl(perr[0], F_SETFL, O_NONBLOCK); if (interactive) - range = &(Filerange){ .start = pos, .end = pos }; + *range = (Filerange){ .start = pos, .end = pos }; /* ranges which are written to the filter and read back in */ Filerange rout = *range; -- cgit v1.2.3