~kaction/dvtm

02b456740c6f647d11239e918f0f4b8f52c89f44 — Semyon Maryasin 3 years ago 640f7a0
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.
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: