~martanne/dvtm

a7bbe62eeadf25f5ead5588cba12da93cd567c75 — Semyon Maryasin 6 years ago 91a7538
Fix minor memory leak in command line parsing

realpath(..., NULL) allocates buffer of size MAX_PATH bytes.
Then, setenv() copies the string it got (unlike putenv()).
So we should free this string, or else it is leaked.

Close #76
1 files changed, 2 insertions(+), 1 deletions(-)

M dvtm.c
M dvtm.c => dvtm.c +2 -1
@@ 1796,11 1796,12 @@ parse_args(int argc, char *argv[]) {
				updatebarpos();
				break;
			case 'c': {
				const char *fifo;
				char *fifo;
				cmdfifo.fd = open_or_create_fifo(argv[++arg], &cmdfifo.file);
				if (!(fifo = realpath(argv[arg], NULL)))
					error("%s\n", strerror(errno));
				setenv("DVTM_CMD_FIFO", fifo, 1);
				free(fifo);
				break;
			}
			default: