vt: fix plumbsel(), snarfsel()
- plumbsel() - remove debug prints - use smalloc() to convert to bytes - fix spurious -1 close of plumb fd - snarfsel() - fix rune buffer leak in open error case
This commit is contained in:
parent
de9aa721f6
commit
80cd634c4d
|
@ -958,38 +958,42 @@ snarfsel(void)
|
|||
Biobuf *b;
|
||||
Rune *r;
|
||||
|
||||
b = Bopen("/dev/snarf", OWRITE|OTRUNC);
|
||||
if(b == nil)
|
||||
if((r = selrunes()) == nil)
|
||||
return;
|
||||
r = selrunes();
|
||||
if(!r)
|
||||
if((b = Bopen("/dev/snarf", OWRITE|OTRUNC)) == nil){
|
||||
free(r);
|
||||
return;
|
||||
}
|
||||
Bprint(b, "%S", r);
|
||||
Bterm(b);
|
||||
free(r);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
plumbsel(void)
|
||||
{
|
||||
char buf[1024], wdir[512];
|
||||
char *s, wdir[1024];
|
||||
Rune *r;
|
||||
int plumb;
|
||||
|
||||
print("plumb\n");
|
||||
if(getwd(wdir, sizeof wdir) == 0)
|
||||
return;
|
||||
if((r = selrunes()) == nil)
|
||||
return;
|
||||
print("wdir: %s, runes: %S\n", wdir, r);
|
||||
if((plumb = plumbopen("send", OWRITE)) != -1){
|
||||
snprint(buf, sizeof buf, "%S", r);
|
||||
print("buf: '%s'\n", buf);
|
||||
plumbsendtext(plumb, "vt", nil, wdir, buf);
|
||||
if((s = smprint("%S", r)) == nil){
|
||||
free(r);
|
||||
return;
|
||||
}
|
||||
close(plumb);
|
||||
free(r);
|
||||
if(getwd(wdir, sizeof wdir) == nil){
|
||||
free(s);
|
||||
return;
|
||||
}
|
||||
if((plumb = plumbopen("send", OWRITE)) < 0){
|
||||
free(s);
|
||||
return;
|
||||
}
|
||||
plumbsendtext(plumb, "vt", nil, wdir, s);
|
||||
close(plumb);
|
||||
free(s);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue