mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
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
This commit is contained in:
parent
19075d934b
commit
f87ea6d4b9
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user