(gl_raster_font) Fix invalid read when pushing vertices

Calling both glsl shader->set_coords() or gl_coord_array_add() resulted
in an invalid read when memcpy()ing coords->lut_tex_coord.
This commit is contained in:
Higor Eurípedes 2015-05-19 13:45:22 -03:00
parent 815b61ecba
commit dc5460effd
2 changed files with 5 additions and 2 deletions

View File

@ -199,7 +199,7 @@ bool gl_coord_array_add(gl_coord_array_t *ca, const gl_coords_t *coords, unsigne
if (success) if (success)
{ {
size_t base_size = coords->vertices * sizeof(GLfloat); size_t base_size = count * sizeof(GLfloat);
size_t offset = ca->coords.vertices; size_t offset = ca->coords.vertices;
/* XXX: i wish we used interlaced arrays so we could call memcpy only once */ /* XXX: i wish we used interlaced arrays so we could call memcpy only once */

View File

@ -29,6 +29,8 @@
font_color[ 4 * (6 * i + c) + 1] = color[1]; \ font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \ font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \ font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 4 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 4 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]; \
} while(0) } while(0)
#define MAX_MSG_LEN_CHUNK 64 #define MAX_MSG_LEN_CHUNK 64
@ -181,6 +183,7 @@ static void gl_raster_font_render_message(
GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK];
GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK]; GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK];
GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK]; GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK];
GLfloat font_lut_tex_coord[2 * 6 * MAX_MSG_LEN_CHUNK];
struct gl_coords coords; struct gl_coords coords;
gl_t *gl = font ? font->gl : NULL; gl_t *gl = font ? font->gl : NULL;
@ -246,7 +249,7 @@ static void gl_raster_font_render_message(
coords.vertex = font_vertex; coords.vertex = font_vertex;
coords.color = font_color; coords.color = font_color;
coords.vertices = 6 * msg_len; coords.vertices = 6 * msg_len;
coords.lut_tex_coord = gl->coords.lut_tex_coord; coords.lut_tex_coord = font_lut_tex_coord;
if (font->block) if (font->block)
gl_coord_array_add(&font->block->carr, &coords, coords.vertices); gl_coord_array_add(&font->block->carr, &coords, coords.vertices);