diff --git a/cups/dest-options.c b/cups/dest-options.c index 892b59578..cc17dce7e 100644 --- a/cups/dest-options.c +++ b/cups/dest-options.c @@ -2161,7 +2161,11 @@ cups_collection_string( bufptr ++; } - *bufptr = '\0'; + if (bufptr < bufend) + *bufptr = '\0'; + else if (bufsize > 0) + *bufend = '\0'; + return ((size_t)(bufptr - buffer + 1)); }