don't write to buf if len == 0
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11095 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 2000, 2002 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -53,8 +53,10 @@ strsep_copy(const char **stringp, const char *delim, char *buf, size_t len)
|
|||||||
return -1;
|
return -1;
|
||||||
*stringp = *stringp + strcspn(*stringp, delim);
|
*stringp = *stringp + strcspn(*stringp, delim);
|
||||||
l = min(len, *stringp - save);
|
l = min(len, *stringp - save);
|
||||||
|
if(len > 0) {
|
||||||
memcpy(buf, save, l);
|
memcpy(buf, save, l);
|
||||||
buf[l] = '\0';
|
buf[l] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
l = *stringp - save;
|
l = *stringp - save;
|
||||||
if(**stringp == '\0')
|
if(**stringp == '\0')
|
||||||
|
Reference in New Issue
Block a user