libventi: fix segfault in vtreadpacket when not connected

This problem happens especially in fossil/view when vtread
can be called even if not connected to venti.

The old libventi handle this case properly in the function vtRPC, which is called by vtReadPacket (client.c).

R=rsc
CC=plan9port.codebot
http://codereview.appspot.com/5484044
This commit is contained in:
David du Colombier 2011-12-12 16:44:50 -05:00 committed by Russ Cox
parent ca81de0ae1
commit 73392c2c7c

View file

@ -65,6 +65,11 @@ vtreadpacket(VtConn *z, uchar score[VtScoreSize], uint type, int n)
if(memcmp(score, vtzeroscore, VtScoreSize) == 0) if(memcmp(score, vtzeroscore, VtScoreSize) == 0)
return packetalloc(); return packetalloc();
if(z == nil){
werrstr("not connected");
return nil;
}
if(z->version[1] == '2' && n >= (1<<16)) { if(z->version[1] == '2' && n >= (1<<16)) {
werrstr("read count too large for protocol"); werrstr("read count too large for protocol");
return nil; return nil;