The crash may be platform/STL/configuration-dependent, see the comment
below.
What is the expected output? What do you see instead?
I expect it to work as if no dictionary was specified, as a compressor,
looking for string re-occurences within a single input file; or, if that
is not desired behaivior, printing an error message.
Instead it crashes.
Platform:
Microsoft Visual Studio 2008 Version 9.0.21022.8 RTM
OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 2 Build 2600
The crash takes place within STL, when empty dictionary is indexed by [0]
here:
dictionary.resize(dictionarysize);
if (fread(&dictionary[0], 1, dictionary_size, dictionary_file)
!= dictionary_size) {
In Debug configuration, STL debug assertion _DEBUG_ERROR("vector subscript
out of range"); is triggered.
Certain STL implementation in some configurations may allow taking an
address of a first element of an empty vector, even if this address is
technically NULL. If this address is never dereferened (which is a natural
assumption since the size is zero), this never leads to a crash; but it is
not a safe practice.
Original issue 6 created by stas@sl.iae.nsk.su on 2008-09-11T05:57:48.000Z:
What steps will reproduce the problem?
The crash may be platform/STL/configuration-dependent, see the comment below.
What is the expected output? What do you see instead? I expect it to work as if no dictionary was specified, as a compressor, looking for string re-occurences within a single input file; or, if that is not desired behaivior, printing an error message.
Instead it crashes.
Platform: Microsoft Visual Studio 2008 Version 9.0.21022.8 RTM OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 2 Build 2600
The crash takes place within STL, when empty dictionary is indexed by [0] here: dictionary.resize(dictionarysize); if (fread(&dictionary[0], 1, dictionary_size, dictionary_file) != dictionary_size) {
In Debug configuration, STL debug assertion _DEBUG_ERROR("vector subscript out of range"); is triggered.
Certain STL implementation in some configurations may allow taking an address of a first element of an empty vector, even if this address is technically NULL. If this address is never dereferened (which is a natural assumption since the size is zero), this never leads to a crash; but it is not a safe practice.
STLPort has a similar check is _STLP_DEBUG mode.