This code does not make much sense from modern compiler point of view.
I need to investigate further but it looks like under certain circumstances it might allow reading beyond vch.end() and could be similar to heart-bleed bug of OpenSSL http://en.wikipedia.org/wiki/Heartbleed
It might take me a bit to understand all of the cases this method is involved with, meanwhile here is the fix.