Skip to content

Commit 9673003

Browse files
committed
FIX: protect against out of bound hatch styles
1 parent 9435bbc commit 9673003

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/libphigs/wsgl/wsgl_attr.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ void wsgl_setup_line_attr(
676676
break;
677677

678678
default:
679+
glLineStipple(2, 0xffff);
679680
glDisable(GL_LINE_STIPPLE);
680681
break;
681682
}
@@ -845,8 +846,10 @@ void wsgl_setup_int_attr_nocol(
845846
}
846847

847848
if (style_ind != wsgl->dev_st.int_style_ind) {
848-
glPolygonStipple(wsgl_hatch_tbl[style_ind - 1]);
849-
wsgl->dev_st.int_style_ind = style_ind;
849+
if (style_ind > 0 && style_ind<7){
850+
glPolygonStipple(wsgl_hatch_tbl[style_ind - 1]);
851+
wsgl->dev_st.int_style_ind = style_ind;
852+
}
850853
}
851854

852855
if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_INT_SHAD_METH)) {
@@ -1014,6 +1017,7 @@ void wsgl_setup_edge_attr(
10141017
break;
10151018

10161019
default:
1020+
glLineStipple(2, 0xffff);
10171021
glDisable(GL_LINE_STIPPLE);
10181022
break;
10191023
}

src/libphigs/wsgl/wsgl_text.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ static void wsgl_text_string3(
502502
posa.y = text->pos.y;
503503
posa.z = text->pos.z;
504504
str = text->char_string;
505+
glLineStipple(2, 0xffff);
505506
glDisable(GL_LINE_STIPPLE);
506507

507508
wsgl_set_text_align3(text, ast, posa, &pos);
@@ -576,6 +577,7 @@ static void wsgl_anno_text_string3(
576577
wsgl_set_anno_text_align3(text, ast, posa, &pos);
577578

578579
str = text->char_string;
580+
glLineStipple(2, 0xffff);
579581
glDisable(GL_LINE_STIPPLE);
580582

581583
len = strlen(str);
@@ -742,6 +744,7 @@ static void wsgl_text_char3(
742744
posa.y = text->pos.y;
743745
posa.z = text->pos.z;
744746
wsgl_set_text_align3(text, ast, posa, &pos);
747+
glLineStipple(2, 0xffff);
745748
glDisable(GL_LINE_STIPPLE);
746749

747750
str = text->char_string;
@@ -840,6 +843,7 @@ static void wsgl_anno_text_char3(
840843
posa.z = text->pos.z;
841844
wsgl_set_anno_text_align3(text, ast, posa, &pos);
842845
str = text->char_string;
846+
glLineStipple(2, 0xffff);
843847
glDisable(GL_LINE_STIPPLE);
844848

845849
len = strlen(str);
@@ -1050,6 +1054,7 @@ static void wsgl_text_stroke3(
10501054
posa.z = text->pos.z;
10511055
wsgl_set_text_align3(text, ast, posa, &pos);
10521056

1057+
glLineStipple(2, 0xffff);
10531058
glDisable(GL_LINE_STIPPLE);
10541059
str = text->char_string;
10551060

@@ -1165,6 +1170,7 @@ static void wsgl_anno_text_stroke3(
11651170
posa.z = text->pos.z;
11661171
wsgl_set_anno_text_align3(text, ast, posa, &pos);
11671172
str = text->char_string;
1173+
glLineStipple(2, 0xffff);
11681174
glDisable(GL_LINE_STIPPLE);
11691175

11701176
len = strlen(str);
@@ -1247,6 +1253,7 @@ void wsgl_text(
12471253
Ptext text;
12481254
Ppoint *pos = (Ppoint *) tdata;
12491255

1256+
glLineStipple(2, 0xffff);
12501257
glDisable(GL_LINE_STIPPLE);
12511258
memcpy(&text.pos, pos, sizeof(Ppoint));
12521259
text.char_string = (char *) &pos[1];
@@ -1294,6 +1301,7 @@ void wsgl_text3(
12941301
Pfloat length, alpha;
12951302
Ppoint3 tlcpos, wcpos;
12961303

1304+
glLineStipple(2, 0xffff);
12971305
glDisable(GL_LINE_STIPPLE);
12981306
memcpy(&wcpos, pos, sizeof(Ppoint3));
12991307
planep = (Pvec3 *)&pos[1];

0 commit comments

Comments
 (0)