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

[spot] Fix abort trap with NotoNastaliqUrdu #520

Merged
merged 8 commits into from
Aug 1, 2018
36 changes: 24 additions & 12 deletions c/spot/source/GPOS.c
Original file line number Diff line number Diff line change
Expand Up @@ -3543,6 +3543,15 @@ static void showContext2(ContextPosFormat2 *fmt, IntX level, void *feattag)
GlyphId glyphId2 = *da_INDEX(CR->glyphidlist, c);
strcpy(name2, getGlyphName(glyphId2, forProofing));
psIndex = strlen(proofString);
if ((psIndex + strlen(name2) + 2) >= kProofBufferLen)
{
if (level == 7)
fprintf(OUTPUTBUFF, "%s", proofString);
else if (level == 8)
dumpMessage(proofString, ((Card32 *)feattag)[0]);
proofString[0] = 0;
psIndex = 0;
}
sprintf(&proofString[psIndex]," %s", name2);
}

Expand All @@ -3565,16 +3574,16 @@ static void showContext2(ContextPosFormat2 *fmt, IntX level, void *feattag)
char name2[MAX_NAME_LEN];
GlyphId glyphId2 = *da_INDEX(CR->glyphidlist, c);
strcpy(name2, getGlyphName(glyphId2, forProofing));
if ((psIndex + strlen(name2) + 10) >= kProofBufferLen)
{
if (level == 7)
fprintf(OUTPUTBUFF, "\n %s", proofString);
else if (level == 8)
dumpMessage(proofString, ((Card32 *)feattag)[0]);
proofString[0] = 0;
psIndex = 0;
}
psIndex = strlen(proofString);
psIndex = strlen(proofString);
if ((psIndex + strlen(name2) + 10) >= kProofBufferLen)
{
if (level == 7)
fprintf(OUTPUTBUFF, "\n %s", proofString);
else if (level == 8)
dumpMessage(proofString, ((Card32 *)feattag)[0]);
proofString[0] = 0;
psIndex = 0;
}
sprintf(&proofString[psIndex]," %s", name2);
}
psIndex = strlen(proofString);
Expand Down Expand Up @@ -3607,9 +3616,12 @@ static void showContext2(ContextPosFormat2 *fmt, IntX level, void *feattag)
for (i = 0; i < fmt->PosClassSetCnt; i++)
{
if (classList[i].glyphidlist.size > 0)
da_FREE(classList[i].glyphidlist);
{
da_FREE(classList[i].glyphidlist);
}
}
memFree(classList);
memFree(classList);
return;
}


Expand Down
4 changes: 2 additions & 2 deletions c/spot/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jmp_buf mark;
#define MAX_ARGS 200


Byte8 *version = "3.5.65517"; /* Program version */
Byte8 *libversion = "3.5.65517"; /* Library version */
Byte8 *version = "3.5.65518"; /* Program version */
Byte8 *libversion = "3.5.65518"; /* Library version */
char * sourcepath;
char * outputfilebase = NULL;
char *infilename=NULL;
Expand Down
34 changes: 34 additions & 0 deletions tests/spot_data/expected_output/bug465_otf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# Printing lookup 1 in feature 'test' for script 'DLFT' language 'dflt'.
# --- Start Lookup [1])
# -------- SubTable 0
context [ g1_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g2_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g3_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g4_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g5_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g6_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g7_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g8_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g9_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g10_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g11_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g12_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g13_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g14_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g15_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g16_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g17_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g18_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g19_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g20_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g21_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_]
[ g1_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g2_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g3_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g4_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g5_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g6_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g7_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g8_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g9_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g10_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g11_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g12_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g13_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g14_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_
g15_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g16_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g17_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g18_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g19_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g20_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ g21_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ ] {
# --- Start Lookup [0])
# -------- SubTable 0
at index 0 pos g1_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g2_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g3_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g4_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g5_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g6_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g7_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g8_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g9_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g10_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g11_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g12_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g13_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g14_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g15_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g16_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g17_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g18_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g19_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g20_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
at index 0 pos g21_234567890_1234567890_1234567890_1234567890_1234567890_1234567890_ <0 0 10 0>;
# --- End Lookup [0])
} context;

# --- End Lookup [1])
Binary file added tests/spot_data/input/bug465/bug465.otf
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/spot_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,17 @@ def test_bug373(font_format):
actual_path = runner(CMD + ['-r', '-o', 't', '_GSUB=7', '-f', file_name])
expected_path = _get_expected_path('bug373_{}.txt'.format(font_format))
assert differ([expected_path, actual_path])


def test_bug465():
""" Fix bug where a fixed length string buffer was overrun. The test
font was built by building an otf from makeotf/data/input/t1pfa.pfa,
dumping this to ttx, and then hand-editing the ttx file to have
empty charstrings, and a ContextPos lookup type 7, format 2.
Hand-editing the ttx was needed as makeotf does not build this
lookup type, nor this post rule format. This test validates that the
current spot code correctly reports the test font GPOS table."""
file_name = "bug465/bug465.otf"
actual_path = runner(CMD + ['-r', '-o', 't', '_GPOS=7', '-f', file_name])
expected_path = _get_expected_path('bug465_otf.txt')
assert differ([expected_path, actual_path])