X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/3d88e64dfcf5dc0fd361ce0c504c67a9196ce44c..72e8da4264659149cce87bf8e757f8cdb3d4ba0f:/misc.c diff --git a/misc.c b/misc.c index 3fea3746..1bd556e6 100644 --- a/misc.c +++ b/misc.c @@ -1,3 +1,7 @@ +/* + * Platform-independent routines shared between all PuTTY programs. + */ + #include #include #include @@ -11,9 +15,12 @@ char *dupstr(const char *s) { - int len = strlen(s); - char *p = snewn(len + 1, char); - strcpy(p, s); + char *p = NULL; + if (s) { + int len = strlen(s); + p = snewn(len + 1, char); + strcpy(p, s); + } return p; } @@ -178,6 +185,8 @@ void bufchain_add(bufchain *ch, const void *data, int len) { const char *buf = (const char *)data; + if (len == 0) return; + ch->buffersize += len; if (ch->tail && ch->tail->buflen < BUFFER_GRANULE) {