diff options
author | Jorg Schuler <jcsjcs@users.sourceforge.net> | 2007-11-10 03:56:11 +0000 |
---|---|---|
committer | Jorg Schuler <jcsjcs@users.sourceforge.net> | 2007-11-10 03:56:11 +0000 |
commit | 5b0e8e39ada5b2b9d4821d8b65a2165e29dcea74 (patch) | |
tree | e6b4a6a70afdc890402c4f2e85c8aa2429587a20 | |
parent | d816863a53a6d029ddb537bd41b3c8c5dec2b9bd (diff) | |
download | libgpod-5b0e8e39ada5b2b9d4821d8b65a2165e29dcea74.tar.gz libgpod-5b0e8e39ada5b2b9d4821d8b65a2165e29dcea74.tar.xz libgpod-5b0e8e39ada5b2b9d4821d8b65a2165e29dcea74.zip |
* src/db-artwork-parser.c (parse_mhba): fix double g_free on mhba
chunks with multiple mhods. Currently only mhods of type 1 are
handled, the rest (type 2: image transition style) are being
discarded.
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1768 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/db-artwork-parser.c | 46 |
2 files changed, 37 insertions, 16 deletions
@@ -1,3 +1,10 @@ +2007-11-10 Jorg Schuler <jcsjcs at users.sourceforge.net> + + * src/db-artwork-parser.c (parse_mhba): fix double g_free on mhba + chunks with multiple mhods. Currently only mhods of type 1 are + handled, the rest (type 2: image transition style) are being + discarded. + 2007-11-09 Jorg Schuler <jcsjcs at users.sourceforge.net> * src/db-parse-context.c (db_parse_context_get_m_header_internal): diff --git a/src/db-artwork-parser.c b/src/db-artwork-parser.c index 81db5a8..bbeba53 100644 --- a/src/db-artwork-parser.c +++ b/src/db-artwork-parser.c @@ -26,6 +26,7 @@ #include <config.h> #endif +#include <stdio.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> @@ -315,8 +316,6 @@ static int parse_mhba (DBParseContext *ctx, GError *error) { MhbaHeader *mhba; - ArtworkDB_MhodHeader *mhod; - DBParseContext *mhod_ctx; DBParseContext *mhia_ctx; Itdb_PhotoAlbum *album; Itdb_PhotoDB *photodb; @@ -352,22 +351,37 @@ parse_mhba (DBParseContext *ctx, GError *error) ctx->byte_order); cur_offset = ctx->header_len; - mhod_ctx = db_parse_context_get_sub_context (ctx, cur_offset); num_children = get_gint32 (mhba->num_mhods, ctx->byte_order); - while ((num_children > 0) && (mhod_ctx != NULL)) { - MhodHeaderArtworkType1 *mhod1; - /* FIXME: First mhod is album name, whats the others for? */ - mhod = db_parse_context_get_m_header (mhod_ctx, ArtworkDB_MhodHeader, "mhod"); - if (mhod == NULL) { - return -1; - } - db_parse_context_set_total_len (mhod_ctx, get_gint32(mhod->total_len, ctx->byte_order)); - mhod1 = (MhodHeaderArtworkType1*)mhod; - album->name = g_strndup ((gchar *)mhod1->string, get_gint32(mhod1->string_len, ctx->byte_order)); - cur_offset += mhod_ctx->total_len; - dump_mhod_type_1 (mhod1); + while (num_children > 0) + { + MhodHeaderArtworkType1 *mhod1; + ArtworkDB_MhodHeader *mhod; + DBParseContext *mhod_ctx; + + mhod_ctx = db_parse_context_get_sub_context (ctx, cur_offset); + /* FIXME: First mhod is album name, whats the others for? */ + mhod = db_parse_context_get_m_header (mhod_ctx, + ArtworkDB_MhodHeader, "mhod"); + if (mhod == NULL) { g_free (mhod_ctx); - num_children--; + return -1; + } + db_parse_context_set_total_len (mhod_ctx, + get_gint32(mhod->total_len, ctx->byte_order)); + mhod1 = (MhodHeaderArtworkType1*)mhod; + switch (mhod1->type) + { /* FIXME: type==1 is album name. type==2 seems to be + * the transtition type between photos, + * e.g. "Dissolve". Not handled yet. */ + case 1: + album->name = g_strndup ((gchar *)mhod1->string, + get_gint32(mhod1->string_len, ctx->byte_order)); + dump_mhod_type_1 (mhod1); + break; + } + cur_offset += mhod_ctx->total_len; + g_free (mhod_ctx); + num_children--; } mhia_ctx = db_parse_context_get_sub_context (ctx, cur_offset); |