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
diff --git a/src/libventi/client.c b/src/libventi/client.c
index 9f200f4..f76fd34 100644
--- a/src/libventi/client.c
+++ b/src/libventi/client.c
@@ -65,6 +65,11 @@
if(memcmp(score, vtzeroscore, VtScoreSize) == 0)
return packetalloc();
+ if(z == nil){
+ werrstr("not connected");
+ return nil;
+ }
+
if(z->version[1] == '2' && n >= (1<<16)) {
werrstr("read count too large for protocol");
return nil;