diff --git a/ChangeLog b/ChangeLog index f2ed319d5588c81c3730cc7e7141d620d5227ebf..e30dd7a257ae9953181f2171c956aee21db2272d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,11 @@ CVS code - - chars.c: mbstrchr() - Make parameter c const. (DLR) +- utils.c: + ngetdelim() + - Do sanity checks manually again instead of in an assert, and + set errno to EINVAL as well as return -1 if they fail. This + matches the manual page. (DLR) - winio.c: edit_scroll() - Redraw the lines before and after the scrolled region even if diff --git a/src/utils.c b/src/utils.c index f8f4d8a76786ee7416ce1fd861e2ab916d336bab..49bcbd270edce2ac259271afb0515108f14bc037 100644 --- a/src/utils.c +++ b/src/utils.c @@ -3,7 +3,7 @@ * utils.c * * * * Copyright (C) 1999-2004 Chris Allegretta * - * Copyright (C) 2005 David Lawrence Ramsey * + * Copyright (C) 2005-2006 David Lawrence Ramsey * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2, or (at your option) * @@ -197,7 +197,10 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream) int c; /* Sanity checks. */ - assert(lineptr != NULL && n != NULL && stream != NULL); + if (lineptr == NULL || n == NULL || stream == NULL) { + errno = EINVAL; + return -1; + } /* Allocate the line the first time. */ if (*lineptr == NULL) {