diff --git a/ChangeLog b/ChangeLog index dbebbb738690f656c0b8333bc35bce9cb68d3b22..d6e4a5d32b808ab7d65394f1340c5bdaf5ee77b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * src/rcfile.c (parse_binding): Check the value of shortcut->toggle only if it actually is a toggle. Found with valgrind. * src/files.c (write_lockfile): Plug a leak. Found with valgrind. + * src/rcfile.c (parse_binding): Plug a tiny leak. 2015-08-02 Benno Schulenberg <bensberg@justemail.net> * src/files.c (initialize_buffer): Initialize also openfile->syntax. diff --git a/src/rcfile.c b/src/rcfile.c index da7b32cf0ebbcaba83f5caa582d0ac8deab46622..6b0f16910dcbffdb7c1c1c18374503859469c853 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -444,7 +444,7 @@ void parse_binding(char *ptr, bool dobind) if (strlen(keycopy) < 2) { rcfile_error(N_("Key name is too short")); - return; + goto free_copy; } /* Uppercase only the first two or three characters of the key name. */ @@ -455,7 +455,7 @@ void parse_binding(char *ptr, bool dobind) keycopy[2] = toupper(keycopy[2]); else { rcfile_error(N_("Key name is too short")); - return; + goto free_copy; } } @@ -465,7 +465,7 @@ void parse_binding(char *ptr, bool dobind) keycopy[1] = tolower(keycopy[1]); else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') { rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\"")); - return; + goto free_copy; } if (dobind) { @@ -474,7 +474,7 @@ void parse_binding(char *ptr, bool dobind) if (funcptr[0] == '\0') { rcfile_error(N_("Must specify a function to bind the key to")); - return; + goto free_copy; } } @@ -484,21 +484,21 @@ void parse_binding(char *ptr, bool dobind) if (menuptr[0] == '\0') { /* TRANSLATORS: Do not translate the word "all". */ rcfile_error(N_("Must specify a menu (or \"all\") in which to bind/unbind the key")); - return; + goto free_copy; } if (dobind) { newsc = strtosc(funcptr); if (newsc == NULL) { rcfile_error(N_("Cannot map name \"%s\" to a function"), funcptr); - return; + goto free_copy; } } menu = strtomenu(menuptr); if (menu < 1) { rcfile_error(N_("Cannot map name \"%s\" to a menu"), menuptr); - return; + goto free_copy; } #ifdef DEBUG @@ -531,7 +531,7 @@ void parse_binding(char *ptr, bool dobind) if (!menu) { rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr); free(newsc); - return; + goto free_copy; } newsc->keystr = keycopy; @@ -546,7 +546,7 @@ void parse_binding(char *ptr, bool dobind) if (check_bad_binding(newsc)) { rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr); free(newsc); - return; + goto free_copy; } } @@ -571,8 +571,11 @@ void parse_binding(char *ptr, bool dobind) /* Add the new shortcut at the start of the list. */ newsc->next = sclist; sclist = newsc; - } else - free(keycopy); + return; + } + + free_copy: + free(keycopy); }