Check decoder's state function for NULL before calling it

Fixes bug reported by Peter Friend
(http://lists.zeromq.org/pipermail/zeromq-dev/2012-November/019425.html)
This commit is contained in:
Martin Hurton 2012-11-21 22:50:55 +01:00 committed by Pieter Hintjens
parent ae8c4a4adf
commit 9120741719

View File

@ -148,6 +148,10 @@ namespace zmq
// False is returned if the decoder has encountered an error. // False is returned if the decoder has encountered an error.
bool stalled () bool stalled ()
{ {
// Check whether there was decoding error.
if (unlikely (static_cast <T*> (this)->next == NULL))
return false;
while (!to_read) { while (!to_read) {
if (!(static_cast <T*> (this)->*next) ()) { if (!(static_cast <T*> (this)->*next) ()) {
if (unlikely (!(static_cast <T*> (this)->next))) if (unlikely (!(static_cast <T*> (this)->next)))