mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
Handle absolute pathnames correctly in dtc_open_file.
Also, free file->dir when freeing file. Signed-off-by: Scott Wood <scottwood@freescale.com>
This commit is contained in:
parent
7d24bd0a72
commit
5695e99d5f
1 changed files with 12 additions and 0 deletions
12
srcpos.c
12
srcpos.c
|
@ -86,6 +86,16 @@ struct dtc_file *dtc_open_file(const char *fname,
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fname[0] == '/') {
|
||||||
|
file->file = fopen(fname, "r");
|
||||||
|
|
||||||
|
if (!file->file)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
file->name = strdup(fname);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
if (!search)
|
if (!search)
|
||||||
search = &default_search;
|
search = &default_search;
|
||||||
|
|
||||||
|
@ -100,6 +110,7 @@ struct dtc_file *dtc_open_file(const char *fname,
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
free((void *)file->dir);
|
||||||
free(file);
|
free(file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -109,5 +120,6 @@ void dtc_close_file(struct dtc_file *file)
|
||||||
if (fclose(file->file))
|
if (fclose(file->file))
|
||||||
die("Error closing \"%s\": %s\n", file->name, strerror(errno));
|
die("Error closing \"%s\": %s\n", file->name, strerror(errno));
|
||||||
|
|
||||||
|
free((void *)file->dir);
|
||||||
free(file);
|
free(file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue