mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 14:41:36 +08:00
Fixed segfault due to partial support of * modifier in tfscanf
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1086 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
d7b089fbcf
commit
c8e27cb8f8
@ -446,13 +446,11 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) {
|
||||
|
||||
{
|
||||
double fval = streamtofloat(stream);
|
||||
switch(rank) {
|
||||
case RANK_INT:
|
||||
if (!(flags & FL_SPLAT)) {
|
||||
if (rank == RANK_INT)
|
||||
*va_arg(ap, float *) = static_cast<float>(fval);
|
||||
break;
|
||||
case RANK_LONG:
|
||||
else if (rank == RANK_LONG)
|
||||
*va_arg(ap, double *) = static_cast<double>(fval);
|
||||
break;
|
||||
}
|
||||
converted++;
|
||||
}
|
||||
@ -466,7 +464,7 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) {
|
||||
bail = BAIL_EOF;
|
||||
break;
|
||||
}
|
||||
*sarg++ = q;
|
||||
if (!(flags & FL_SPLAT)) *sarg++ = q;
|
||||
}
|
||||
if (!bail)
|
||||
converted++;
|
||||
@ -482,13 +480,15 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) {
|
||||
ungetc(q, stream);
|
||||
break;
|
||||
}
|
||||
*sp++ = q;
|
||||
if (!(flags & FL_SPLAT)) *sp = q;
|
||||
sp++;
|
||||
}
|
||||
if (sarg != sp) {
|
||||
if (sarg == sp) {
|
||||
bail = BAIL_EOF;
|
||||
} else if (!(flags & FL_SPLAT)) {
|
||||
*sp = '\0'; // Terminate output
|
||||
converted++;
|
||||
} else {
|
||||
bail = BAIL_EOF;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -553,13 +553,14 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) {
|
||||
ungetc(q, stream);
|
||||
break;
|
||||
}
|
||||
*sarg++ = q;
|
||||
if (!(flags & FL_SPLAT)) *sarg = q;
|
||||
sarg++;
|
||||
}
|
||||
if (oarg != sarg) {
|
||||
if (oarg == sarg) {
|
||||
bail = (q <= 0) ? BAIL_EOF : BAIL_ERR;
|
||||
} else if (!(flags & FL_SPLAT)) {
|
||||
*sarg = '\0';
|
||||
converted++;
|
||||
} else {
|
||||
bail = (q <= 0) ? BAIL_EOF : BAIL_ERR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user