{
RbVorbisTagger *o;
vorbis_comment *vc;
- int s;
+ int s, i;
Data_Get_Struct (self, RbVorbisTagger, o);
rb_raise (eVTError, "vcedit_comments() failed - %s",
vcedit_error (o->state));
+ /* check whether all comments are well-formed */
+ for (i = 0; i < vc->comments; i++) {
+ char *ptr, *content = vc->user_comments[i];
+
+ ptr = strchr (content, '=');
+ if (!ptr || ptr == content)
+ rb_raise (eVTError, "malformed comment - %s", content);
+ }
+
o->comments = rb_class_new_instance (0, NULL, cComments);
comments_init (o->comments, o->state);