Commit f1e29cf4 authored by Olivier Aubert's avatar Olivier Aubert

modules/misc/svg.c:

  * specify unit for malloc
  * use g_object_unref to properly free the p_rendition
  * remove spurious whitespace
parent 827a3e6f
......@@ -44,6 +44,7 @@
#include "vlc_block.h"
#include "vlc_filter.h"
#include <glib-object.h> /* g_object_unref( ) */
#include <librsvg-2/librsvg/rsvg.h>
typedef struct svg_rendition_t svg_rendition_t;
......@@ -196,7 +197,7 @@ static char *svg_GetTemplate( vlc_object_t *p_this )
msg_Dbg( p_this, "reading %ld bytes from template %s",
(unsigned long)s.st_size, psz_filename );
psz_template = malloc( s.st_size + 42 );
psz_template = malloc( ( s.st_size + 42 ) * sizeof( char ) );
if( !psz_template )
{
msg_Err( p_filter, "out of memory" );
......@@ -260,8 +261,11 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
if( p_svg->p_rendition == NULL ) {
svg_RenderPicture( p_filter, p_svg );
/* FIXME: should do a check here to ensure that
the rendition went OK */
if( ! p_svg )
{
msg_Err( p_filter, "Cannot render SVG" );
return VLC_EGENERIC;
}
}
i_width = gdk_pixbuf_get_width( p_svg->p_rendition );
i_height = gdk_pixbuf_get_height( p_svg->p_rendition );
......@@ -450,10 +454,11 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
else
{
/* Data is text. Convert to SVG */
/* FIXME: handle p_style attributes */
int length;
char* psz_template = p_sys->psz_template;
length = strlen( psz_string ) + strlen( psz_template ) + 42;
p_svg->psz_text = malloc( length + 1 );
p_svg->psz_text = malloc( ( length + 1 ) * sizeof( char ) );
if( !p_svg->psz_text )
{
msg_Err( p_filter, "out of memory" );
......@@ -480,7 +485,11 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
static void FreeString( svg_rendition_t *p_svg )
{
if( p_svg->psz_text )
free( p_svg->psz_text );
free( p_svg->p_rendition );
/* p_svg->p_rendition is a GdkPixbuf, and its allocation is
managed through ref. counting */
if( p_svg->p_rendition )
g_object_unref( p_svg->p_rendition );
free( p_svg );
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment