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 for UB caused by null pointer arithmetic #126

Merged
merged 2 commits into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all 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: 5 additions & 2 deletions 3rdparty/plutovg/plutovg-ft-stroker.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,12 @@ static void ft_stroke_border_export(PVG_FT_StrokeBorder border,
PVG_FT_Outline* outline)
{
/* copy point locations */
memcpy(outline->points + outline->n_points, border->points,
border->num_points * sizeof(PVG_FT_Vector));
if (outline->points != NULL && border->points != NULL)
memcpy(outline->points + outline->n_points, border->points,
border->num_points * sizeof(PVG_FT_Vector));

/* copy tags */
if (outline->tags)
{
PVG_FT_UInt count = border->num_points;
PVG_FT_Byte* read = border->tags;
Expand All @@ -649,6 +651,7 @@ static void ft_stroke_border_export(PVG_FT_StrokeBorder border,
}

/* copy contours */
if (outline->contours)
{
PVG_FT_UInt count = border->num_points;
PVG_FT_Byte* tags = border->tags;
Expand Down
10 changes: 7 additions & 3 deletions 3rdparty/plutovg/plutovg-rle.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ static void ft_outline_init(PVG_FT_Outline* outline, plutovg_t* pluto, int point

PVG_FT_Byte* data = pluto->outline_data;
outline->points = (PVG_FT_Vector*)(data);
outline->tags = (char*)(data + size_a);
outline->contours = (int*)(data + size_a + size_b);
outline->contours_flag = (char*)(data + size_a + size_b + size_c);
outline->tags = outline->contours_flag = NULL;
outline->contours = NULL;
if(data){
outline->tags = (char*)(data + size_a);
outline->contours = (int*)(data + size_a + size_b);
outline->contours_flag = (char*)(data + size_a + size_b + size_c);
}
outline->n_points = 0;
outline->n_contours = 0;
outline->flags = 0x0;
Expand Down