-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler compatibility and unicode termination fixes #55
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -49,17 +49,19 @@ ID3v2_CommentFrame* CommentFrame_parse(CharStream* frame_cs, const int id3_major | |||||||
CharStream_read(frame_cs, lang, ID3v2_COMMENT_FRAME_LANGUAGE_LENGTH); | ||||||||
|
||||||||
const int short_desc_size = ID3v2_strlent(CharStream_get_cur(frame_cs)); | ||||||||
char short_desc[short_desc_size]; | ||||||||
char* short_desc = malloc(short_desc_size * sizeof (char)); | ||||||||
CharStream_read(frame_cs, short_desc, short_desc_size); | ||||||||
|
||||||||
const int comment_size = ID3v2_strlent(CharStream_get_cur(frame_cs)); | ||||||||
char comment[comment_size]; | ||||||||
char* comment = malloc(comment_size * sizeof(char)); | ||||||||
CharStream_read(frame_cs, comment, comment_size); | ||||||||
|
||||||||
ID3v2_CommentFrame* frame = CommentFrame_new(header->flags, lang, short_desc, comment); | ||||||||
|
||||||||
FrameHeader_free(header); // we only needed the header to parse the data | ||||||||
|
||||||||
free(comment); | ||||||||
free(short_desc); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
return frame; | ||||||||
} | ||||||||
|
||||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -37,13 +37,19 @@ ID3v2_TextFrame* TextFrame_parse(CharStream* frame_cs, const int id3_major_versi | |||||||
CharStream_seek(frame_cs, ID3v2_FRAME_ENCODING_LENGTH, SEEK_CUR); // skip encoding | ||||||||
|
||||||||
const int text_size = header->size - ID3v2_FRAME_ENCODING_LENGTH; | ||||||||
char text[text_size]; | ||||||||
const size_t string_termination_bytes = 2; | ||||||||
char* text = malloc((string_termination_bytes + text_size) * sizeof(char)); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's been a while since I've worked on this, but, doesn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on mp3's I've worked with, there's no termination, so it's not included |
||||||||
CharStream_read(frame_cs, text, text_size); | ||||||||
|
||||||||
// Adding string termination bytes in case the stored string doesn't have those | ||||||||
for (int i = 0; i < string_termination_bytes; ++i) | ||||||||
text[text_size + i] = 0x00; | ||||||||
Comment on lines
+44
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this due to a malformed id3tag embedded in the mp3? or how can we reach that scenario? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, why do we need a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that it's not malformed, but intended - there's no zeroes after the strings in actual mp3 files, I've checked multiple mp3 files I've had. Probably because storing the string + its length is sufficient for them. So we want to put those zeros into the RAM ourselves, if we want to rely on strlen-like functions. Regarding |
||||||||
|
||||||||
ID3v2_TextFrame* frame = TextFrame_new(header->id, header->flags, text); | ||||||||
|
||||||||
FrameHeader_free(header); // we only needed the header to parse the data | ||||||||
|
||||||||
free(text); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also think we can group those |
||||||||
return frame; | ||||||||
} | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.