mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-26 22:59:38 +03:00
utils: don't accept NULL for the string to be copied
This should not occur, so crash when it does happen.
This commit is contained in:
parent
b4a5fac744
commit
46566572d6
@ -316,9 +316,6 @@ void *nrealloc(void *ptr, size_t howmuch)
|
||||
* freeing the destination. Usage: "dest = mallocstrncpy(dest, src, n);". */
|
||||
char *mallocstrncpy(char *dest, const char *src, size_t n)
|
||||
{
|
||||
if (src == NULL)
|
||||
src = "";
|
||||
|
||||
dest = charealloc(dest, n);
|
||||
strncpy(dest, src, n);
|
||||
|
||||
@ -329,7 +326,7 @@ char *mallocstrncpy(char *dest, const char *src, size_t n)
|
||||
* "dest = mallocstrcpy(dest, src);". */
|
||||
char *mallocstrcpy(char *dest, const char *src)
|
||||
{
|
||||
return mallocstrncpy(dest, src, (src == NULL) ? 1 : strlen(src) + 1);
|
||||
return mallocstrncpy(dest, src, strlen(src) + 1);
|
||||
}
|
||||
|
||||
/* Return an allocated copy of the given string. */
|
||||
|
Loading…
Reference in New Issue
Block a user