mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-02-17 11:00:47 +01: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 };
|
||||
|
||||
char *script = prepend_helpers(p->script, p->script_len - 1);
|
||||
char *script = prepend_helpers(p->script, p->script_len);
|
||||
char *args[] = SHELL_ARGS(script);
|
||||
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 *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);
|
||||
abort();
|
||||
}
|
||||
|
||||
b = buf;
|
||||
mlen = LEN(scr_helpers_sh);
|
||||
memcpy(b, scr_helpers_sh, mlen);
|
||||
l = helpers_len;
|
||||
memcpy(b, scr_helpers_sh, l * sizeof(*b));
|
||||
|
||||
b += (mlen - 1) * sizeof(*str);
|
||||
mlen = len;
|
||||
memcpy(b, str, mlen);
|
||||
|
||||
b += mlen * sizeof(*str);
|
||||
b[0] = '\0';
|
||||
b += l * sizeof(*str);
|
||||
l = len;
|
||||
memcpy(b, str, l * sizeof(*b));
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user