diff options
author | andmarti1424 <scim.spreadsheet@gmail.com> | 2015-09-02 22:25:32 -0300 |
---|---|---|
committer | andmarti1424 <scim.spreadsheet@gmail.com> | 2015-09-02 22:25:32 -0300 |
commit | 1912aa4b33657f699d5780abb115725739765a01 (patch) | |
tree | 7303b6552706c9dd7b092058a490c7cc9d540e71 | |
parent | 24c5cce42855a665449afae6beb8e36d2e918054 (diff) |
fix in import_csv
-rw-r--r-- | src/file.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -752,13 +752,18 @@ int import_csv(char * fname, char d) { c = 0; while( token != NULL ) { + if (r > MAXROWS - GROWAMT - 1 || c > ABSMAXCOLS - 1) break; clean_carrier(token); if ( token[0] == '\"' && token[strlen(token)-1] == '\"') { quote = 1; } else if ( (token[0] == '\"' || quote) && strlen(token) && (token[strlen(token)-1] != '\"' || strlen(token) == 1) ) { quote = 1; - sprintf(token + strlen(token), "%s", xstrtok(NULL, delim)); - continue; + char * next = xstrtok(NULL, delim); + + if (next != NULL) { + sprintf(token + strlen(token), "%s", next); + continue; + } } if (quote) { // elimino comillas si vengo de quote del_char(token, 0); @@ -778,6 +783,7 @@ int import_csv(char * fname, char d) { } r++; + if (r > MAXROWS - GROWAMT - 1 || c > ABSMAXCOLS - 1) break; } //scdebug("END"); |