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:
Johan Danielsson
2002-08-14 17:20:40 +00:00
parent 2a485ca058
commit 3625b3f37b

View File

@@ -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).
* All rights reserved.
*
@@ -53,8 +53,10 @@ strsep_copy(const char **stringp, const char *delim, char *buf, size_t len)
return -1;
*stringp = *stringp + strcspn(*stringp, delim);
l = min(len, *stringp - save);
memcpy(buf, save, l);
buf[l] = '\0';
if(len > 0) {
memcpy(buf, save, l);
buf[l] = '\0';
}
l = *stringp - save;
if(**stringp == '\0')