Corrected several improper uses of StrDup() that used the first
argument as a pointer but also set the same variable to the return value. This is ambiguous, because the behavior depends on whether the value being set upon return is the original value or the reallocated value. The result is system-dependent behavior.
This commit is contained in:
parent
53a488989f
commit
28d8808c65
|
|
@ -3758,12 +3758,12 @@ cmdDumpParseArgs(cmdName, w, cmd, dummy, scx)
|
|||
}
|
||||
TxError("Renaming cell to \"%s\" to avoid conflict.", newcellname);
|
||||
def = DBCellNewDef(cellnameptr);
|
||||
def->cd_file = StrDup(&def->cd_file, fullpathname);
|
||||
StrDup(&def->cd_file, fullpathname);
|
||||
freeMagic(newcellname);
|
||||
}
|
||||
}
|
||||
else
|
||||
def->cd_file = StrDup(&def->cd_file, fullpathname);
|
||||
StrDup(&def->cd_file, fullpathname);
|
||||
freeMagic(fullpathname);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@ DBFileRecovery(filename)
|
|||
continue;
|
||||
|
||||
recent = sbuf.st_ctime;
|
||||
DBbackupFile = StrDup(&DBbackupFile, tempname);
|
||||
StrDup(&DBbackupFile, tempname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -762,7 +762,7 @@ DBFileRecovery(filename)
|
|||
}
|
||||
else
|
||||
{
|
||||
DBbackupFile = StrDup(&DBbackupFile, filename);
|
||||
StrDup(&DBbackupFile, filename);
|
||||
recent = 1;
|
||||
}
|
||||
|
||||
|
|
@ -1066,7 +1066,7 @@ dbReadOpen(cellDef, name, setFileName, errptr)
|
|||
|
||||
/* Write the new path to cd_file or else magic will */
|
||||
/* generate another error later. */
|
||||
cellDef->cd_file = StrDup(&cellDef->cd_file, filename);
|
||||
StrDup(&cellDef->cd_file, filename);
|
||||
|
||||
TxError("The cell exists in the search paths at %s.\n", filename);
|
||||
TxError("The discovered version will be used.\n");
|
||||
|
|
@ -1098,7 +1098,7 @@ dbReadOpen(cellDef, name, setFileName, errptr)
|
|||
realname = (char *) mallocMagic((unsigned) (strlen(cellDef->cd_name)
|
||||
+ strlen(DBSuffix) + 1));
|
||||
(void) sprintf(realname, "%s%s", cellDef->cd_name, DBSuffix);
|
||||
cellDef->cd_file = StrDup(&cellDef->cd_file, realname);
|
||||
StrDup(&cellDef->cd_file, realname);
|
||||
}
|
||||
if (errptr) TxError("%s\n", strerror(*errptr));
|
||||
|
||||
|
|
@ -2736,7 +2736,7 @@ DBCellWrite(cellDef, fileName)
|
|||
/* surprises can occur after saving a file as a different */
|
||||
/* filename. */
|
||||
|
||||
cellDef->cd_file = StrDup(&cellDef->cd_file, fileName);
|
||||
StrDup(&cellDef->cd_file, fileName);
|
||||
|
||||
/* The cd_file should not have the .mag suffix, but make sure */
|
||||
/* it doesn't before adding one. */
|
||||
|
|
@ -3322,7 +3322,7 @@ DBWriteBackup(filename)
|
|||
return FALSE;
|
||||
}
|
||||
close(fd);
|
||||
DBbackupFile = StrDup(&DBbackupFile, template);
|
||||
StrDup(&DBbackupFile, template);
|
||||
freeMagic(template);
|
||||
TxPrintf("Created database crash recovery file %s\n", DBbackupFile);
|
||||
}
|
||||
|
|
@ -3332,10 +3332,10 @@ DBWriteBackup(filename)
|
|||
{
|
||||
if (strlen(filename) == 0)
|
||||
{
|
||||
DBbackupFile = StrDup(&DBbackupFile, (char *)NULL);
|
||||
StrDup(&DBbackupFile, (char *)NULL);
|
||||
return TRUE;
|
||||
}
|
||||
DBbackupFile = StrDup(&DBbackupFile, filename);
|
||||
StrDup(&DBbackupFile, filename);
|
||||
TxPrintf("Created database crash recovery file %s\n", DBbackupFile);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ resistChanged:
|
|||
}
|
||||
#endif
|
||||
else
|
||||
EFStyle = StrDup(&EFStyle, argv[1]);
|
||||
StrDup(&EFStyle, argv[1]);
|
||||
break;
|
||||
|
||||
/* version version-number */
|
||||
|
|
|
|||
Loading…
Reference in New Issue