From 3625b3f37b23c0b5cafbb908be541aca41989dd7 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Wed, 14 Aug 2002 17:20:40 +0000 Subject: [PATCH] don't write to buf if len == 0 git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11095 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/roken/strsep_copy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/roken/strsep_copy.c b/lib/roken/strsep_copy.c index df09f9cdc..ace41f688 100644 --- a/lib/roken/strsep_copy.c +++ b/lib/roken/strsep_copy.c @@ -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')