tweaks: keep the const qualifier of the syntax name [coverity scan]
Also, reduce the scope of the 'line' variable.master
parent
252dc138a2
commit
b4fd08fa5e
11
src/files.c
11
src/files.c
|
@ -1930,9 +1930,9 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||||
/* If we must set the filename, and it changed, adjust things. */
|
/* If we must set the filename, and it changed, adjust things. */
|
||||||
if (!nonamechange && strcmp(openfile->filename, realname) != 0) {
|
if (!nonamechange && strcmp(openfile->filename, realname) != 0) {
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
char *newname;
|
const char *oldname, *newname;
|
||||||
char *oldname = openfile->syntax ? openfile->syntax->name : "";
|
|
||||||
filestruct *line = openfile->fileage;
|
oldname = openfile->syntax ? openfile->syntax->name : "";
|
||||||
#endif
|
#endif
|
||||||
openfile->filename = mallocstrcpy(openfile->filename, realname);
|
openfile->filename = mallocstrcpy(openfile->filename, realname);
|
||||||
|
|
||||||
|
@ -1945,9 +1945,12 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||||
|
|
||||||
/* If the syntax changed, discard and recompute the multidata. */
|
/* If the syntax changed, discard and recompute the multidata. */
|
||||||
if (strcmp(oldname, newname) != 0) {
|
if (strcmp(oldname, newname) != 0) {
|
||||||
for (; line != NULL; line = line->next) {
|
filestruct *line = openfile->fileage;
|
||||||
|
|
||||||
|
while (line != NULL) {
|
||||||
free(line->multidata);
|
free(line->multidata);
|
||||||
line->multidata = NULL;
|
line->multidata = NULL;
|
||||||
|
line = line->next;
|
||||||
}
|
}
|
||||||
precalc_multicolorinfo();
|
precalc_multicolorinfo();
|
||||||
refresh_needed = TRUE;
|
refresh_needed = TRUE;
|
||||||
|
|
Loading…
Reference in New Issue