diff options
author | Scott Wood <scottwood@freescale.com> | 2008-01-04 15:10:45 -0600 |
---|---|---|
committer | Jon Loeliger <jdl@freescale.com> | 2008-01-07 09:20:21 -0600 |
commit | 5695e99d5f6418f8f5b990bdcb1f153935d0fb06 (patch) | |
tree | 4c9427c16790a56f41dbcf3c357d67a2b16184da | |
parent | 7d24bd0a725264495edb679477d14a87145bbbf8 (diff) | |
download | dtc-5695e99d5f6418f8f5b990bdcb1f153935d0fb06.zip dtc-5695e99d5f6418f8f5b990bdcb1f153935d0fb06.tar.gz dtc-5695e99d5f6418f8f5b990bdcb1f153935d0fb06.tar.bz2 |
Handle absolute pathnames correctly in dtc_open_file.
Also, free file->dir when freeing file.
Signed-off-by: Scott Wood <scottwood@freescale.com>
-rw-r--r-- | srcpos.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -86,6 +86,16 @@ struct dtc_file *dtc_open_file(const char *fname, return file; } + if (fname[0] == '/') { + file->file = fopen(fname, "r"); + + if (!file->file) + goto out; + + file->name = strdup(fname); + return file; + } + if (!search) search = &default_search; @@ -100,6 +110,7 @@ struct dtc_file *dtc_open_file(const char *fname, } out: + free((void *)file->dir); free(file); return NULL; } @@ -109,5 +120,6 @@ void dtc_close_file(struct dtc_file *file) if (fclose(file->file)) die("Error closing \"%s\": %s\n", file->name, strerror(errno)); + free((void *)file->dir); free(file); } |