]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
If neither SIGINFO nor SIGUSR1 is being used, don't crash.
authorTim Kientzle <kientzle@gmail.com>
Fri, 26 Jun 2009 04:18:37 +0000 (00:18 -0400)
committerTim Kientzle <kientzle@gmail.com>
Fri, 26 Jun 2009 04:18:37 +0000 (00:18 -0400)
SVN-Revision: 1182

tar/siginfo.c

index f5e3d88ac853d57cf7d6eff88699cf0cff13d3b6..e7e41b3a05df0cfd029fad20f1308c944a32dcf6 100644 (file)
@@ -102,7 +102,7 @@ void
 siginfo_init(struct bsdtar *bsdtar)
 {
        /* Set the strings to NULL so that free() is safe. */
-       bsdtar->siginfo->path = bsdtar->siginfo->oper = NULL;
+       bsdtar->siginfo = NULL;
 }
 #endif
 
@@ -112,6 +112,8 @@ siginfo_setinfo(struct bsdtar *bsdtar, const char * oper, const char * path,
 {
 
        /* Free old operation and path strings. */
+       if (bsdtar->siginfo == NULL)
+               return;
        free(bsdtar->siginfo->oper);
        free(bsdtar->siginfo->path);
 
@@ -160,10 +162,12 @@ siginfo_done(struct bsdtar *bsdtar)
        sigaction(SIGUSR1, &bsdtar->siginfo->sigusr1_old, NULL);
 #endif
 
-       /* Free strings. */
-       free(bsdtar->siginfo->path);
-       free(bsdtar->siginfo->oper);
+       if (bsdtar->siginfo) {
+               /* Free strings. */
+               free(bsdtar->siginfo->path);
+               free(bsdtar->siginfo->oper);
 
-       /* Free internal data structure. */
-       free(bsdtar->siginfo);
+               /* Free internal data structure. */
+               free(bsdtar->siginfo);
+       }
 }