[librsvg] Plug a mem leak
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Plug a mem leak
- Date: Fri, 11 Nov 2011 21:54:24 +0000 (UTC)
commit 0171a4e1d4a4634d3ebe209ae1422426c9a12685
Author: Christian Persch <chpe gnome org>
Date: Fri Nov 11 22:53:51 2011 +0100
Plug a mem leak
Don't leak the CRDocHandler.
==988== 104 (92 direct, 12 indirect) bytes in 1 blocks are definitely lost in loss record 4,805 of 5,382
==988== at 0x402AD89: malloc (vg_replace_malloc.c:236)
==988== by 0x4B40BDA: standard_malloc (gmem.c:85)
==988== by 0x4053A15: rsvg_parse_cssbuffer (rsvg-styles.c:1128)
==988== by 0x4056644: rsvg_style_handler_free (rsvg-base.c:90)
==988== by 0x4056BB9: rsvg_end_element (rsvg-base.c:681)
==988== by 0x49C28C1: xmlParseEndTag1 (parser.c:8356)
==988== by 0x49C9DEB: xmlParseTryOrFinish (parser.c:11154)
==988== by 0x49CAB24: xmlParseChunk (parser.c:11739)
==988== by 0x405A238: rsvg_handle_write (rsvg-base.c:1172)
rsvg-styles.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/rsvg-styles.c b/rsvg-styles.c
index 32b61e4..e685eb2 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -1120,7 +1120,6 @@ init_sac_handler (CRDocHandler * a_handler)
void
rsvg_parse_cssbuffer (RsvgHandle * ctx, const char *buff, size_t buflen)
{
- enum CRStatus status = CR_OK;
CRParser *parser = NULL;
CRDocHandler *css_handler = NULL;
CSSUserData user_data;
@@ -1133,16 +1132,17 @@ rsvg_parse_cssbuffer (RsvgHandle * ctx, const char *buff, size_t buflen)
/* TODO: fix libcroco to take in const strings */
parser = cr_parser_new_from_buf ((guchar *) buff, (gulong) buflen, CR_UTF_8, FALSE);
- status = cr_parser_set_sac_handler (parser, css_handler);
-
- if (status != CR_OK) {
- g_warning (_("Error setting CSS SAC handler\n"));
- cr_parser_destroy (parser);
+ if (parser == NULL) {
+ g_warning (_("Error creating CSS parser\n"));
+ cr_doc_handler_unref (css_handler);
return;
}
- status = cr_parser_set_use_core_grammar (parser, FALSE);
- status = cr_parser_parse (parser);
+ cr_parser_set_sac_handler (parser, css_handler);
+ cr_doc_handler_unref (css_handler);
+
+ cr_parser_set_use_core_grammar (parser, FALSE);
+ cr_parser_parse (parser);
cr_parser_destroy (parser);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]