Merge the following changes from NetBSD:

history.c 1.32:
  # Fix memory leak found by valgrind (Julien Torres)
map.c 1.24:
  # fix debugging printf format.
read.c 1.40:
  # Fix bug with multiple pending el_pushes. Reported by Julien Torres.
tty.c 1.24:
  # Coverity CID 1216: Prevent negative index use.

MFC after:	3 weeks
This commit is contained in:
Stefan Farfeleder 2007-03-11 21:47:40 +00:00
parent 86b3ea3634
commit f9ff2f8ffb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=167464
4 changed files with 37 additions and 16 deletions

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $NetBSD: history.c,v 1.31 2005/08/01 14:34:06 christos Exp $
* $NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@ -543,6 +543,7 @@ history_end(History *h)
if (h->h_next == history_def_next)
history_def_clear(h->h_ref, &ev);
h_free(h->h_ref);
h_free(h);
}

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $NetBSD: map.c,v 1.23 2006/03/06 21:11:56 christos Exp $
* $NetBSD: map.c,v 1.24 2006/04/09 01:36:51 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@ -1381,7 +1381,7 @@ map_bind(EditLine *el, int argc, const char **argv)
break;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type\n", ntype));
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
break;
}
return (0);

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $NetBSD: read.c,v 1.39 2005/08/02 12:11:14 christos Exp $
* $NetBSD: read.c,v 1.40 2007/03/01 21:41:45 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@ -55,6 +55,7 @@ private int read__fixio(int, int);
private int read_preread(EditLine *);
private int read_char(EditLine *, char *);
private int read_getcmd(EditLine *, el_action_t *, char *);
private void read_pop(c_macro_t *);
/* read_init():
* Initialize the read stuff
@ -299,6 +300,19 @@ read_char(EditLine *el, char *cp)
return (num_read);
}
/* read_pop():
* Pop a macro from the stack
*/
private void
read_pop(c_macro_t *ma)
{
int i;
el_free(ma->macro[0]);
for (i = ma->level--; i > 0; i--)
ma->macro[i - 1] = ma->macro[i];
ma->offset = 0;
}
/* el_getc():
* Read a character
@ -315,20 +329,22 @@ el_getc(EditLine *el, char *cp)
if (!read_preread(el))
break;
}
if (ma->level < 0)
break;
if (ma->macro[ma->level][ma->offset] == '\0') {
el_free(ma->macro[ma->level--]);
ma->offset = 0;
if (ma->macro[0][ma->offset] == '\0') {
read_pop(ma);
continue;
}
*cp = ma->macro[ma->level][ma->offset++] & 0377;
if (ma->macro[ma->level][ma->offset] == '\0') {
*cp = ma->macro[0][ma->offset++] & 0377;
if (ma->macro[0][ma->offset] == '\0') {
/* Needed for QuoteMode On */
el_free(ma->macro[ma->level--]);
ma->offset = 0;
read_pop(ma);
}
return (1);
}

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $NetBSD: tty.c,v 1.23 2005/06/01 11:37:52 lukem Exp $
* $NetBSD: tty.c,v 1.24 2006/03/18 09:07:05 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@ -1149,10 +1149,14 @@ tty_stty(EditLine *el, int argc __unused, const char **argv)
st = len =
strlen(el->el_tty.t_t[z][m->m_type].t_name);
}
x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
? '+' : '\0';
x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
? '-' : x;
if (i != -1) {
x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
? '+' : '\0';
x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
? '-' : x;
} else {
x = '\0';
}
if (x != '\0' || aflag) {