X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=ext%2Fvcedit.c;h=393ca9d14c0033034ecf56592b1bd1c86285c94d;hb=d13cef8ffe7aa8f764e91c4914e120eb5857376e;hp=832f417b2b30519cba6661b3dfb063c52a43f925;hpb=b1c729d53273c482052dfc99e197463b123e389e;p=ruby-vorbistagger.git diff --git a/ext/vcedit.c b/ext/vcedit.c index 832f417..393ca9d 100644 --- a/ext/vcedit.c +++ b/ext/vcedit.c @@ -40,8 +40,6 @@ struct vcedit_state_St { vorbis_comment vc; vorbis_info vi; - char filename[PATH_MAX]; - FILE *in; bool opened; long serial; @@ -53,6 +51,8 @@ struct vcedit_state_St { int prevW; int extrapage; int eosin; + + char filename[0]; }; static void @@ -82,8 +82,13 @@ vcedit_state * vcedit_state_new (const char *filename) { vcedit_state *state; + size_t len; + + len = strlen (filename); + if (len > PATH_MAX) + return NULL; - state = malloc (sizeof (vcedit_state)); + state = malloc (sizeof (vcedit_state) + len + 1); if (!state) return NULL; @@ -94,8 +99,7 @@ vcedit_state_new (const char *filename) return NULL; } - snprintf (state->filename, sizeof (state->filename), - "%s", filename); + strcpy (state->filename, filename); return state; }