ivankosenko/open-vcdiff

vcdiff crashes with zero-size dictionary

Closed this issue · 4 comments

What steps will reproduce the problem?
1. Create empty file empty.dict
2. Create a non-empty file sample.txt
3. vcdiff encode --dictionary empty.dict < sample.txt > out.delta

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(dictionary_size);
  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.

Original issue reported on code.google.com by s...@sl.iae.nsk.su on 11 Sep 2008 at 5:57

Thank you for reporting these problems and investigating them.

Original comment by lincoln1...@gmail.com on 22 Oct 2008 at 10:40

  • Changed state: Accepted
[deleted comment]
(Sorry, I gave the wrong e-mail address a minute ago.)
If you would care to mail your full name to openvcdiff [at] gmail [dot] com, I 
will 
be happy to add you to the THANKS file for this project.

Original comment by openvcd...@gmail.com on 23 Oct 2008 at 12:20

Fixed in open-vcdiff v0.4.  Please let me know if you find that the problem 
still 
exists.  Thanks again for your interest in open-vcdiff and for reporting these 
issues with the Visual Studio-built executable.

Original comment by openvcd...@gmail.com on 24 Oct 2008 at 12:19

  • Changed state: Fixed