Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #940: saveBlend() handles zero or one blend only #941

Merged
merged 4 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions c/public/lib/source/cffread/cffread.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ static void saveBlend(cfrCtx h, float *realValue, abfOpEntry *blendEntry) {
blendEntry->value = *realValue;
blendEntry->numBlends = 0; /* shows there is no blend value, and the regular value shoud be used instead. */
blendEntry->blendValues = NULL;
} else {
} else if (numBlends == 1) {
int i;
float defaultValue;
signed int numRegions = h->stack.numRegions;
Expand All @@ -974,15 +974,16 @@ static void saveBlend(cfrCtx h, float *realValue, abfOpEntry *blendEntry) {
// copy the defaul region value
blendValues[0] = defaultValue = INDEX_REAL(0);

/* now, copy the blend abusolate values to blendArray[i].
/* now, copy the blend absolate values to blendArray[i].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean absolute?

(Otherwise these changes looks fine to me.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I didn't realize there are two typos in one word... will fix

The default region value is in stackEntry->int_val or real_val
The region delta values are in the stackEntry->blend_val array.
*/

for (i = 0; i < numRegions; i++) {
blendValues[i + 1] = stackEntry->blend_val[i] + defaultValue;
}
}
} else
fatal(h, cfrErrDICTOp);
}

/* Save integer array operands. */
Expand Down
Binary file added tests/tx_data/input/bad/bug940_private_blend.otf
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/tx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,3 +841,11 @@ def test_bad_charset():
runner(CMD + ['-a', '-f', font_path, save_path])
expected_path = get_expected_path('bad_charset.txt')
assert differ([expected_path, save_path, '-s', '## Filename'])


def test_bug_940():
input_path = get_bad_input_path('bug940_private_blend.otf')
output_path = get_temp_file_path()
with pytest.raises(subprocess.CalledProcessError) as err:
runner(CMD + ['-a', '-o', 'cff2', '-f', input_path, output_path])
assert(err.value.returncode > 0) # error code, not segfault or success