chiark / gitweb /
cope with 0-length messages in oprintf, and do tryflush just before bombing due to...
authorian <ian>
Sun, 4 May 2008 21:49:59 +0000 (21:49 +0000)
committerian <ian>
Sun, 4 May 2008 21:49:59 +0000 (21:49 +0000)
hostside/obc.c

index 6eafc192cb506f5856365206d45def457acb1c47..c522afb4258ec7db063cbb6dc7434918edc04bb6 100644 (file)
@@ -78,6 +78,7 @@ static void addlink(OutBufferChain *ch, OutBuffer *ob) {
     char what[128];
     snprintf(what,sizeof(what)-1,"`%.*s...'", ob->l,ob->m);
     what[sizeof(what)-1]= 0;
+    obc_tryflush(ch);
     ch->error(ch,"buffer limit exceeded",what);
   }
 }
@@ -100,7 +101,9 @@ void ovprintf(OutBufferChain *ch, const char *fmt, va_list al) {
   OutBuffer *ob;
 
   ob= mmalloc(sizeof(*ob));
-  ob->l= vasprintf(&ob->m, fmt, al);  if (ob->l <= 0) diem();
+  ob->l= vasprintf(&ob->m, fmt, al);
+  if (ob->l < 0) diem();
+  if (!ob->l) { free(ob->m); free(ob); return; }
   addlink(ch, ob);
 }