diff options
author | drh <drh@noemail.net> | 2013-07-12 21:09:24 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-07-12 21:09:24 +0000 |
commit | 8dd675e43f8c59a2802aec13a9a3d8d0b36dbc8a (patch) | |
tree | 44c4e5e9209e63447aeb2c949d9b606f6a6d8cee /src | |
parent | a95882ff39517ddcd163fe307134b2705aace26c (diff) | |
download | sqlite-8dd675e43f8c59a2802aec13a9a3d8d0b36dbc8a.tar.gz sqlite-8dd675e43f8c59a2802aec13a9a3d8d0b36dbc8a.zip |
Make sure the shell does not try to put a zero terminator on the end of an
unallocated zero-length string when running ".import" on an empty file.
FossilOrigin-Name: 92adaee5bd31c152dbc1592f4aeb5d8da957a1ea
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/shell.c b/src/shell.c index 79548fa1e..f0815538a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1721,7 +1721,6 @@ static char *csv_read_one_field(CSVReader *p){ || (c==EOF && pc==cQuote) ){ do{ p->n--; }while( p->z[p->n]!=cQuote ); - p->z[p->n] = 0; p->cTerm = c; break; } @@ -1732,7 +1731,6 @@ static char *csv_read_one_field(CSVReader *p){ if( c==EOF ){ fprintf(stderr, "%s:%d: unterminated %c-quoted field\n", p->zFile, startLine, cQuote); - p->z[p->n] = 0; p->cTerm = EOF; break; } @@ -1748,9 +1746,9 @@ static char *csv_read_one_field(CSVReader *p){ p->nLine++; if( p->n>1 && p->z[p->n-1]=='\r' ) p->n--; } - p->z[p->n] = 0; p->cTerm = c; } + if( p->z ) p->z[p->n] = 0; return p->z; } |