ref: fd5ced871042acc294faa2dd2118ad8fe2c61ea2
parent: aa140ab528a68eeb2f9843a6b757036fecb83925
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Sep 1 14:47:39 EDT 2018
fswstat: can't modify automatic variables that get used in waseror() handler
--- a/kern/devfs-posix.c
+++ b/kern/devfs-posix.c
@@ -422,13 +422,13 @@
char *base, *newpath;
base = strdup(uif->path);
+ *lastelem(base) = 0;
+ newpath = catpath(base, d.name);
+ free(base);
if(waserror()){
- free(base);
+ free(newpath);
nexterror();
}
- *lastelem(base) = 0;
- newpath = catpath(base, d.name);
- free(base), base = newpath;
if(rename(uif->path, newpath) < 0)
error(strerror(errno));
free(uif->path);
--- a/kern/devfs-win32.c
+++ b/kern/devfs-win32.c
@@ -634,7 +634,12 @@
error(Ebadstat);
base[l] = 0;
newpath = catpath(base, d.name, nil);
- free(base), base = newpath;
+ free(base);
+ poperror();
+ if(waserror()){
+ free(newpath);
+ nexterror();
+ }
if(wcscmp(uif->path, newpath)!=0){
if(!MoveFile(uif->path, newpath))
oserror();