From e5e4ea99ece4f9a5f764673164e4f47438eb129a Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Mon, 27 Jan 2014 21:32:12 +0100 Subject: vtx: fixed crash on reading header from invalid VTX file --- plugins/vtx/vtx.c | 1 + plugins/vtx/vtxfile.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'plugins/vtx') diff --git a/plugins/vtx/vtx.c b/plugins/vtx/vtx.c index 27a1f4b1..5ba72aae 100644 --- a/plugins/vtx/vtx.c +++ b/plugins/vtx/vtx.c @@ -257,6 +257,7 @@ vtx_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) { trace ("vtx: failed to read header\n"); return NULL; } + printf ("hdr: %p\n", hdr); trace ("vtx: datasize: %d\n", hdr->regdata_size); DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); diff --git a/plugins/vtx/vtxfile.c b/plugins/vtx/vtxfile.c index ff9914e6..04978a08 100644 --- a/plugins/vtx/vtxfile.c +++ b/plugins/vtx/vtxfile.c @@ -11,6 +11,9 @@ #include "ayemu.h" +//#define trace(...) { fprintf (stderr, __VA_ARGS__); } +#define trace(fmt,...) + #define AYEMU_VTX_STRING_MAX 254 typedef const char * data_ptr_t; @@ -97,7 +100,7 @@ static data_ptr_t read_header(data_ptr_t buf, ayemu_vtx_t **target, size_t size) else if (strncmp (hdr, "ym", 2) == 0) vtx->chiptype = AYEMU_YM; else { - fprintf (stderr, "File is _not_ VORTEX format!\n" + trace ("File is _not_ VORTEX format!\n" "It not begins with 'ay' or 'ym' string.\n"); goto clean_and_ret_null; } @@ -127,7 +130,7 @@ static data_ptr_t read_header(data_ptr_t buf, ayemu_vtx_t **target, size_t size) ayemu_vtx_t * ayemu_vtx_header(data_ptr_t buf, size_t size) { - ayemu_vtx_t *vtx; + ayemu_vtx_t *vtx = NULL; const char *data; -- cgit v1.2.3