files: prevent dereferencing a possible (although very unlikely) NULL

Don't catch the NULL earlier, because we do want an error message when
opening the lockfile fails.
master
Benno Schulenberg 2016-06-04 09:30:41 +02:00
parent 0293eac1d1
commit 9f4b4c975a
1 changed files with 2 additions and 1 deletions

View File

@ -252,7 +252,8 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
snprintf(&lockdata[2], 11, "nano %s", VERSION);
strncpy(&lockdata[28], mypwuid->pw_name, 16);
strncpy(&lockdata[68], myhostname, 31);
strncpy(&lockdata[108], origfilename, 768);
if (origfilename != NULL)
strncpy(&lockdata[108], origfilename, 768);
if (modified == TRUE)
lockdata[1007] = 0x55;