summaryrefslogtreecommitdiffstats
path: root/libtar/handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtar/handle.c')
-rw-r--r--libtar/handle.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libtar/handle.c b/libtar/handle.c
index ae974b9f0..28a7dc247 100644
--- a/libtar/handle.c
+++ b/libtar/handle.c
@@ -31,7 +31,7 @@ static tartype_t default_type = { open, close, read, write };
static int
-tar_init(TAR **t, char *pathname, tartype_t *type,
+tar_init(TAR **t, const char *pathname, tartype_t *type,
int oflags, int mode, int options)
{
if ((oflags & O_ACCMODE) == O_RDWR)
@@ -66,7 +66,7 @@ tar_init(TAR **t, char *pathname, tartype_t *type,
/* open a new tarfile handle */
int
-tar_open(TAR **t, char *pathname, tartype_t *type,
+tar_open(TAR **t, const char *pathname, tartype_t *type,
int oflags, int mode, int options)
{
if (tar_init(t, pathname, type, oflags, mode, options) == -1)
@@ -82,6 +82,7 @@ tar_open(TAR **t, char *pathname, tartype_t *type,
(*t)->fd = (*((*t)->type->openfunc))(pathname, oflags, mode);
if ((*t)->fd == -1)
{
+ libtar_hash_free((*t)->h, NULL);
free(*t);
return -1;
}
@@ -91,7 +92,7 @@ tar_open(TAR **t, char *pathname, tartype_t *type,
int
-tar_fdopen(TAR **t, int fd, char *pathname, tartype_t *type,
+tar_fdopen(TAR **t, int fd, const char *pathname, tartype_t *type,
int oflags, int mode, int options)
{
if (tar_init(t, pathname, type, oflags, mode, options) == -1)
@@ -121,6 +122,8 @@ tar_close(TAR *t)
libtar_hash_free(t->h, ((t->oflags & O_ACCMODE) == O_RDONLY
? free
: (libtar_freefunc_t)tar_dev_free));
+ if (t->th_pathname != NULL)
+ free(t->th_pathname);
free(t);
return i;