Unified · Split
| @@ -422,13 +422,13 @@ fswstat(Chan *c, uchar *buf, int n) · 421 unmodified lines | ||
| 422 | 422 | char *base, *newpath; |
| 423 | 423 | |
| 424 | 424 | base = strdup(uif->path); |
| 425 | + *lastelem(base) = 0; | |
| 426 | + newpath = catpath(base, d.name); | |
| 427 | + free(base); | |
| 425 | 428 | if(waserror()){ |
| 426 | − free(base); | |
| 429 | + free(newpath); | |
| 427 | 430 | nexterror(); |
| 428 | 431 | } |
| 429 | − *lastelem(base) = 0; | |
| 430 | − newpath = catpath(base, d.name); | |
| 431 | − free(base), base = newpath; | |
| 432 | 432 | if(rename(uif->path, newpath) < 0) |
| 433 | 433 | error(strerror(errno)); |
| 434 | 434 | free(uif->path); |
| @@ -634,7 +634,12 @@ fswstat(Chan *c, uchar *buf, int n) · 633 unmodified lines | ||
| 634 | 634 | error(Ebadstat); |
| 635 | 635 | base[l] = 0; |
| 636 | 636 | newpath = catpath(base, d.name, nil); |
| 637 | − free(base), base = newpath; | |
| 637 | + free(base); | |
| 638 | + poperror(); | |
| 639 | + if(waserror()){ | |
| 640 | + free(newpath); | |
| 641 | + nexterror(); | |
| 642 | + } | |
| 638 | 643 | if(wcscmp(uif->path, newpath)!=0){ |
| 639 | 644 | if(!MoveFile(uif->path, newpath)) |
| 640 | 645 | oserror(); |