libplumb, Mail: fix crash on nil plumb fids

http://codereview.appspot.com/116083
This commit is contained in:
Mathieu Lonjaret 2009-09-12 15:25:51 -04:00
parent 0cadb4301d
commit 7b5db1c35a
2 changed files with 10 additions and 3 deletions

View file

@ -84,9 +84,12 @@ threadmain(int argc, char *argv[])
quotefmtinstall();
/* open these early so we won't miss notification of new mail messages while we read mbox */
plumbsendfd = plumbopenfid("send", OWRITE|OCEXEC);
plumbseemailfd = plumbopenfid("seemail", OREAD|OCEXEC);
plumbshowmailfd = plumbopenfid("showmail", OREAD|OCEXEC);
if((plumbsendfd = plumbopenfid("send", OWRITE|OCEXEC)) == nil)
fprint(2, "warning: open plumb/send: %r\n");
if((plumbseemailfd = plumbopenfid("seemail", OREAD|OCEXEC)) == nil)
fprint(2, "warning: open plumb/seemail: %r\n");
if((plumbshowmailfd = plumbopenfid("showmail", OREAD|OCEXEC)) == nil)
fprint(2, "warning: open plumb/showmail: %r\n");
shortmenu = 0;
srvname = "mail";

View file

@ -138,6 +138,10 @@ plumbrecvfid(CFid *fid)
Plumbmsg *m;
int n, more;
if(fid == nil){
werrstr("invalid fid");
return nil;
}
buf = malloc(8192);
if(buf == nil)
return nil;