Skip to content

Commit 7456ccd

Browse files
authored
r.watershed: use allocated buffer size as arg to snprintf (#7197)
1 parent 6f42ad2 commit 7456ccd

File tree

1 file changed

+4
-2
lines changed
  • raster/r.watershed/front

1 file changed

+4
-2
lines changed

raster/r.watershed/front/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ static int new_argc;
3030
static void do_opt(const struct Option *opt)
3131
{
3232
char *buf;
33+
size_t len;
3334

3435
if (!opt->answer)
3536
return;
36-
buf = G_malloc(strlen(opt->key) + 1 + strlen(opt->answer) + 1);
37-
snprintf(buf, GPATH_MAX, "%s=%s", opt->key, opt->answer);
37+
len = strlen(opt->key) + 1 + strlen(opt->answer) + 1;
38+
buf = G_malloc(len);
39+
snprintf(buf, len, "%s=%s", opt->key, opt->answer);
3840
new_argv[new_argc++] = buf;
3941
}
4042

0 commit comments

Comments
 (0)