mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 13:26:37 +00:00
Fix #1877: malloc: error pointer being freed was not allocated
This commit is contained in:
parent
191e77ec5d
commit
be6988d1c8
17
src/nnn.c
17
src/nnn.c
|
@ -5187,7 +5187,6 @@ static void show_help(const char *path)
|
||||||
"cT Set time type%110 Lock\n"
|
"cT Set time type%110 Lock\n"
|
||||||
"b^L Redraw%18? Help, conf\n"
|
"b^L Redraw%18? Help, conf\n"
|
||||||
};
|
};
|
||||||
char help_buf[1<<11]; // if editing helpstr, ensure this has enough space to decode it
|
|
||||||
|
|
||||||
int fd = create_tmp_file();
|
int fd = create_tmp_file();
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
|
@ -5198,22 +5197,26 @@ static void show_help(const char *path)
|
||||||
get_output(prog, NULL, NULL, fd, FALSE);
|
get_output(prog, NULL, NULL, fd, FALSE);
|
||||||
|
|
||||||
bool hex = true;
|
bool hex = true;
|
||||||
char *w = help_buf;
|
const char space = ' ';
|
||||||
const char *end = helpstr + (sizeof helpstr - 1);
|
const char *end = helpstr + (sizeof helpstr - 1);
|
||||||
|
|
||||||
for (const char *s = helpstr; s < end; ++s) {
|
for (const char *s = helpstr; s < end; ++s) {
|
||||||
if (hex) {
|
if (hex) {
|
||||||
for (int k = 0, n = xchartohex(*s); k < n; ++k) *w++ = ' ';
|
for (int k = 0, n = xchartohex(*s); k < n; ++k)
|
||||||
|
if (write(fd, &space, 1) != 1)
|
||||||
|
break;
|
||||||
} else if (*s == '%') {
|
} else if (*s == '%') {
|
||||||
int n = ((s[1] - '0') * 10) + (s[2] - '0');
|
int n = ((s[1] - '0') * 10) + (s[2] - '0');
|
||||||
for (int k = 0; k < n; ++k) *w++ = ' ';
|
for (int k = 0; k < n; ++k)
|
||||||
|
if (write(fd, &space, 1) != 1)
|
||||||
|
break;
|
||||||
s += 2;
|
s += 2;
|
||||||
} else {
|
} else {
|
||||||
*w++ = *s;
|
if (write(fd, s, 1) != 1)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
hex = *s == '\n';
|
hex = *s == '\n';
|
||||||
}
|
}
|
||||||
ssize_t res = write(fd, help_buf, w - help_buf);
|
|
||||||
(void)res; // silence warning
|
|
||||||
|
|
||||||
dprintf(fd, "\nLOCATIONS\n");
|
dprintf(fd, "\nLOCATIONS\n");
|
||||||
for (uchar_t i = 0; i < CTX_MAX; ++i)
|
for (uchar_t i = 0; i < CTX_MAX; ++i)
|
||||||
|
|
Loading…
Reference in a new issue