From: robertl Date: Tue, 9 Nov 2004 16:54:53 +0000 (+0000) Subject: Fix case when source string consists of nothing but spaces. (Thanx, holux...) X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~11^2~3869 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ba95c3c2feb45fdda0c33737038bf264ced7e280;p=gpsbabel.git Fix case when source string consists of nothing but spaces. (Thanx, holux...) --- diff --git a/gpsbabel/mkshort.c b/gpsbabel/mkshort.c index 1c447244d..19ec3a51e 100644 --- a/gpsbabel/mkshort.c +++ b/gpsbabel/mkshort.c @@ -290,8 +290,12 @@ mkshort(void *h, const char *istring) ostring = nstring; /* Eliminate leading whitespace in all cases */ - while (isspace(ostring[0])) { - memmove(&ostring[0], &ostring[1], strlen(ostring)-1); + while (ostring[0] && isspace(ostring[0])) { + /* If orig string has N bytes, we want to copy N-1 bytes + * of the string itself plus the string terminator (which + * matters if the string consists of nothing but spaces) + */ + memmove(&ostring[0], &ostring[1], strlen(ostring)); } if (!hdl->whitespaceok) {