Skip to content

Commit

Permalink
fix pre-exit bug in str_2_fields()
Browse files Browse the repository at this point in the history
  • Loading branch information
jfzheng committed Jan 12, 2016
1 parent 55150ec commit 9f4cd84
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libsim/sim_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,16 @@ int str_2_fields(char *record, int arrSz, char *fieldArr[])
{
int nkey=0;
char *substr = 0;
int sublen = 0;
str_iter_t iter = str_iter_init(record, 0);
WHILE_GET_FIELD(iter, " ,", " ,", substr) {
if (nkey>0) {
fieldArr[nkey-1][sublen] = 0; /* terminate last substr */
}
fieldArr[nkey++] = substr;
substr[STR_ITER_GET_SUBLEN(iter)] = 0;
sublen = STR_ITER_GET_SUBLEN(iter);
}
fieldArr[nkey-1][sublen] = 0; /* terminate last substr */
return nkey;
}

Expand Down

0 comments on commit 9f4cd84

Please sign in to comment.