don't set buf[len - 1] to '\0' when reading dmenu input

see github issue #94

Since the buffer is initialized to 0, we don't need to
explicitly set the terminating null-byte.

Thanks to losciamano
This commit is contained in:
Sascha Kruse 2013-03-08 08:25:00 +01:00
parent cbf269d055
commit fd1ae14fa3

3
menu.c
View File

@ -165,7 +165,7 @@ void context_menu(void)
if (!dmenu_input) if (!dmenu_input)
return; return;
char buf[1024]; char buf[1024] = {0};
int child_io[2]; int child_io[2];
int parent_io[2]; int parent_io[2];
if (pipe(child_io) != 0) { if (pipe(child_io) != 0) {
@ -204,7 +204,6 @@ void context_menu(void)
size_t len = read(parent_io[0], buf, 1023); size_t len = read(parent_io[0], buf, 1023);
if (len == 0) if (len == 0)
return; return;
buf[len - 1] = '\0';
int status; int status;
waitpid(pid, &status, 0); waitpid(pid, &status, 0);