[vlc-devel] [PATCH 3/7] Puzzle: piece management and drawing

Denis Charmet typx at dinauz.org
Mon Apr 15 17:51:14 CEST 2013


Le lundi 15 avril 2013 à 02:15:36, Vianney Boyer a écrit :
> +int puzzle_bake_pieces_shapes( filter_t *p_filter)
> +{
[...]
> +            if (i_ret != VLC_SUCCESS) return i_ret;
> +            i_ret = puzzle_generate_sectLeft2Right( p_filter,
> &p_sys->ps_pieces_shapes[i_currect_shape+7][i_plane],
> &p_sys->ps_pieces_shapes[i_currect_shape+1][i_plane], i_plane);
> +            if (i_ret != VLC_SUCCESS) return i_ret;
> +        }
> +
> +        free(ps_scale_pts_H);
> +        free(ps_scale_pts_V);
> +        free(ps_neg_pts_H);
> +        free(ps_neg_pts_V);

Those are leaked in all your error cases.

> +/*****************************************************************************
> + * generate data which will be used to draw each line of a piece
> sector based
> + *       on bezier curve
> + *****************************************************************************/
> +int puzzle_generate_sect_bezier( filter_t *p_filter, piece_shape_t
> *ps_piece_shape, uint8_t i_pts_nbr, point_t *ps_pt, uint8_t i_plane,
> uint8_t i_border)
> +{
[...]
> +
> +    int i_ret = puzzle_generate_shape_lines(p_filter,
> ps_piece_shape, i_min_y, i_nb_y, f_x_ratio, f_y_ratio, ps_pt,
> i_pts_nbr, i_border, i_plane);
> +    if (i_ret != VLC_SUCCESS)
> +        return i_ret;
why this if? just return i_ret. (Maybe found in other functions)
> +
> +    return VLC_SUCCESS;
> +}
> +
[...]
> + ps_piece_shape->ps_piece_shape_row[i_row].ps_row_section = malloc
> (  sizeof(row_section_t) * i_sect);
> +            if
> (!ps_piece_shape->ps_piece_shape_row[i_row].ps_row_section) {
> +                for (uint8_t i=0; i<i_row;i++)
> + free(ps_piece_shape->ps_piece_shape_row[i].ps_row_section);
> +                free(ps_piece_shape->ps_piece_shape_row);
> +                return VLC_ENOMEM;
> +            }
I don't have the time right now to check but I suppose that
(ps_piece_shape->ps_piece_shape_row should be freed in another function,
shouldn't it be set to NULL to avoid potential double free?

Regards,

-- 
TypX
Le mauvais esprit est un art de vivre



More information about the vlc-devel mailing list