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