mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-06-24 20:02:07 +02:00
Fix
This commit is contained in:
parent
d2f87bc22f
commit
ee85f98008
@ -123,7 +123,7 @@ static int run(Preview *p, int *exitcode)
|
|||||||
|
|
||||||
int sp_arg[] = { pipe_fds[0], pipe_fds[1], STDERR_FILENO };
|
int sp_arg[] = { pipe_fds[0], pipe_fds[1], STDERR_FILENO };
|
||||||
|
|
||||||
char *script = prepend_helpers(p->script, p->script_len - 1);
|
char *script = prepend_helpers(p->script, p->script_len);
|
||||||
char *args[] = SHELL_ARGS(script);
|
char *args[] = SHELL_ARGS(script);
|
||||||
int ret = spawn(args, NULL, exitcode, spawn_redirect, sp_arg);
|
int ret = spawn(args, NULL, exitcode, spawn_redirect, sp_arg);
|
||||||
|
|
||||||
|
17
shell.c
17
shell.c
@ -12,23 +12,20 @@
|
|||||||
char *prepend_helpers(char *str, size_t len)
|
char *prepend_helpers(char *str, size_t len)
|
||||||
{
|
{
|
||||||
char *buf, *b;
|
char *buf, *b;
|
||||||
size_t mlen;
|
size_t l, helpers_len = LEN(scr_helpers_sh) - 1;
|
||||||
|
|
||||||
if (!(buf = malloc(sizeof(*buf) * (LEN(scr_helpers_sh) + len)))) {
|
if (!(buf = malloc(sizeof(*buf) * (helpers_len + len)))) {
|
||||||
PRINTINTERR(FUNCFAILED("malloc"), ERRNOS);
|
PRINTINTERR(FUNCFAILED("malloc"), ERRNOS);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
b = buf;
|
b = buf;
|
||||||
mlen = LEN(scr_helpers_sh);
|
l = helpers_len;
|
||||||
memcpy(b, scr_helpers_sh, mlen);
|
memcpy(b, scr_helpers_sh, l * sizeof(*b));
|
||||||
|
|
||||||
b += (mlen - 1) * sizeof(*str);
|
b += l * sizeof(*str);
|
||||||
mlen = len;
|
l = len;
|
||||||
memcpy(b, str, mlen);
|
memcpy(b, str, l * sizeof(*b));
|
||||||
|
|
||||||
b += mlen * sizeof(*str);
|
|
||||||
b[0] = '\0';
|
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user