Skip to content
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

Expression: vector subscript out of range #17

Open
TheEeveeLovers opened this issue Feb 17, 2024 · 4 comments
Open

Expression: vector subscript out of range #17

TheEeveeLovers opened this issue Feb 17, 2024 · 4 comments

Comments

@TheEeveeLovers
Copy link

TheEeveeLovers commented Feb 17, 2024

When I try to load captions, the parser doesn't even start because of the following error:
image
Call Stack:

>	SRTSynchedLyrics.exe!std::vector<std::string,std::allocator<std::string>>::operator[](const unsigned __int64 _Pos) Line 1948	C++
 	SRTSynchedLyrics.exe!SubtitleItem::timeMSec(std::string value) Line 313	C++
 	SRTSynchedLyrics.exe!SubtitleItem::SubtitleItem(int subNo, std::string startTime, std::string endTime, std::string text, bool ignore, std::string justDialogue, int speakerCount, int nonDialogueCount, int styleTagCount, int wordCount, std::vector<std::string,std::allocator<std::string>> speaker, std::vector<std::string,std::allocator<std::string>> nonDialogue, std::vector<std::string,std::allocator<std::string>> styleTags, std::vector<std::string,std::allocator<std::string>> word) Line 286	C++
 	SRTSynchedLyrics.exe!SubRipParser::parse(std::string fileName) Line 248	C++
 	SRTSynchedLyrics.exe!SubRipParser::SubRipParser(std::string fileName) Line 262	C++
 	SRTSynchedLyrics.exe!SubtitleParserFactory::getParser() Line 155	C++
 	SRTSynchedLyrics.exe!LoadCaptions(std::string filePath) Line 35	C++
 	SRTSynchedLyrics.exe!startup() Line 212	C++
 	SRTSynchedLyrics.exe!SDL_main(int argc, char * * args) Line 223	C++
 	SRTSynchedLyrics.exe!main_getcmdline() Line 82	C
 	[External Code]	

Code:

void LoadCaptions(std::string filePath) {
	SubtitleParserFactory* subParserFactory = new SubtitleParserFactory(filePath);
	SubtitleParser* parser = subParserFactory->getParser(); // Error suspect
	// More code that doesn't get run due to error
}

LoadCaptions("12 All Apologies 1.srt");

SRT File: (zipped so it can upload to GitHub)
12 All Apologies 1.zip
For reference, this file works completely fine in VLC.

@TheEeveeLovers
Copy link
Author

TheEeveeLovers commented Feb 17, 2024

I added a new line character at the beginning of the SRT file and got the same error, not before getting another
Run-Time Check Failure #3 - The variable 'subNo' is being used without being initialized.
-- srtparser.h, line 248

Call Stack:

>	SRTSynchedLyrics.exe!SubRipParser::parse(std::string fileName) Line 248	C++
 	SRTSynchedLyrics.exe!SubRipParser::SubRipParser(std::string fileName) Line 262	C++
 	SRTSynchedLyrics.exe!SubtitleParserFactory::getParser() Line 155	C++
 	SRTSynchedLyrics.exe!LoadCaptions(std::string filePath) Line 34	C++
 	SRTSynchedLyrics.exe!startup() Line 212	C++
 	SRTSynchedLyrics.exe!SDL_main(int argc, char * * args) Line 223	C++
 	SRTSynchedLyrics.exe!main_getcmdline() Line 82	C
 	[External Code]	

Seems like part of an entirely different bug? Because here, it seems that the new line character (nothing) is being read as the caption index.

@TheEeveeLovers
Copy link
Author

I just tried opening the example SRT, and it worked fine
What's wrong with my file?

@TheEeveeLovers
Copy link
Author

TheEeveeLovers commented Feb 17, 2024

Apparently there's too many captions
Limit is 47

@TheEeveeLovers
Copy link
Author

OK, found the problem
There was an additional space before the arrow on the 48th entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant