Merge pull request #1687 from stweil/cov

Fix 5 issues reported by Coverity Scan
This commit is contained in:
zdenop 2018-06-20 20:29:47 +02:00 committed by GitHub
commit b344dc14ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View File

@ -475,20 +475,22 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) {
if (!(flags & FL_SPLAT)) { if (!(flags & FL_SPLAT)) {
sarg = va_arg(ap, char *); sarg = va_arg(ap, char *);
} }
char *sp = sarg; unsigned length = 0;
while (width--) { while (width--) {
q = fgetc(stream); q = fgetc(stream);
if (isspace(static_cast<unsigned char>(q)) || q <= 0) { if (isspace(static_cast<unsigned char>(q)) || q <= 0) {
ungetc(q, stream); ungetc(q, stream);
break; break;
} }
if (!(flags & FL_SPLAT)) *sp = q; if (!(flags & FL_SPLAT)) {
sp++; sarg[length] = q;
}
length++;
} }
if (sarg == sp) { if (length == 0) {
bail = BAIL_EOF; bail = BAIL_EOF;
} else if (!(flags & FL_SPLAT)) { } else if (!(flags & FL_SPLAT)) {
*sp = '\0'; // Terminate output sarg[length] = '\0'; // Terminate output
converted++; converted++;
} }
} }

View File

@ -354,7 +354,7 @@ static void ExtractFeaturesFromRun(
denorm.NormTransform(root_denorm, prev_normed_pos, &prev_normed_pos); denorm.NormTransform(root_denorm, prev_normed_pos, &prev_normed_pos);
LLSQ points; LLSQ points;
LLSQ dirs; LLSQ dirs;
FCOORD normed_pos; FCOORD normed_pos(0.0f, 0.0f);
int index = GatherPoints(outline, feature_length, denorm, root_denorm, int index = GatherPoints(outline, feature_length, denorm, root_denorm,
start_index, end_index, &pos, &normed_pos, start_index, end_index, &pos, &normed_pos,
&points, &dirs); &points, &dirs);
@ -366,7 +366,7 @@ static void ExtractFeaturesFromRun(
// accumulators. // accumulators.
LLSQ next_points; LLSQ next_points;
LLSQ next_dirs; LLSQ next_dirs;
FCOORD next_normed_pos; FCOORD next_normed_pos(0.0f, 0.0f);
index = GatherPoints(outline, feature_length, denorm, root_denorm, index = GatherPoints(outline, feature_length, denorm, root_denorm,
index, end_index, &pos, &next_normed_pos, index, end_index, &pos, &next_normed_pos,
&next_points, &next_dirs); &next_points, &next_dirs);

View File

@ -84,7 +84,9 @@ ColumnFinder::ColumnFinder(int gridsize,
min_gutter_width_(static_cast<int>(kMinGutterWidthGrid * gridsize)), min_gutter_width_(static_cast<int>(kMinGutterWidthGrid * gridsize)),
mean_column_gap_(tright.x() - bleft.x()), mean_column_gap_(tright.x() - bleft.x()),
tabfind_aligned_gap_fraction_(aligned_gap_fraction), tabfind_aligned_gap_fraction_(aligned_gap_fraction),
deskew_(0.0f, 0.0f),
reskew_(1.0f, 0.0f), rotation_(1.0f, 0.0f), rerotate_(1.0f, 0.0f), reskew_(1.0f, 0.0f), rotation_(1.0f, 0.0f), rerotate_(1.0f, 0.0f),
text_rotation_(0.0f, 0.0f),
best_columns_(nullptr), stroke_width_(nullptr), best_columns_(nullptr), stroke_width_(nullptr),
part_grid_(gridsize, bleft, tright), nontext_map_(nullptr), part_grid_(gridsize, bleft, tright), nontext_map_(nullptr),
projection_(resolution), projection_(resolution),

View File

@ -55,7 +55,7 @@ class QuickTest : public testing::Test {
return instance->classicProgress( progress ); return instance->classicProgress( progress );
}; };
monitor.cancel = []( void* ths, int words ) -> bool { monitor.cancel = []( void* ths, int words ) -> bool {
((ClassicMockProgressSink*)ths)->cancel( words ); return ((ClassicMockProgressSink*)ths)->cancel(words);
}; };
monitor.cancel_this = this; monitor.cancel_this = this;
instance = this; instance = this;