From f87ea6d4b9e55db6dde77997c0b1078f0944eb66 Mon Sep 17 00:00:00 2001 From: Scott R Charlton Date: Tue, 27 Jan 2015 01:59:34 +0000 Subject: [PATCH] fixed f2cstring error that occurred when given an empty string git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@9203 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- src/fwrap.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fwrap.cpp b/src/fwrap.cpp index 43d81ba9..81b3f23a 100644 --- a/src/fwrap.cpp +++ b/src/fwrap.cpp @@ -12,15 +12,15 @@ char * f2cstring(char* fstring, size_t len) { char *cstr, *str; - size_t i; + long i; str = fstring; - for (i = len - 1; i >= 0 && !isgraph((int)str[i]); i--); + for (i = len - 1; i >= 0 && !isgraph((int) str[i]); i--); cstr = (char *) malloc((size_t) (i + 2)); if (!cstr) return 0; cstr[i + 1] = '\0'; - memcpy(cstr,str,i+1); + if ((i + 1) > 0) memcpy(cstr, str, (size_t) (i + 1)); return cstr; }