summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw44@gmail.com>2013-10-13 18:59:48 +0800
committerLAN-TW <lantw44@gmail.com>2013-10-13 18:59:48 +0800
commit40581a99721dd0079e7e183afd2b82f0e3f91ec2 (patch)
treec8dd3655076b8c39808543a3e8d387c0587d51b9
parent3cc8c1017aa2c1bb370e009776c6e9fb5d6c23d5 (diff)
downloadgsoc2013-libgnome-autoar-40581a99721dd0079e7e183afd2b82f0e3f91ec2.tar
gsoc2013-libgnome-autoar-40581a99721dd0079e7e183afd2b82f0e3f91ec2.tar.gz
gsoc2013-libgnome-autoar-40581a99721dd0079e7e183afd2b82f0e3f91ec2.tar.bz2
gsoc2013-libgnome-autoar-40581a99721dd0079e7e183afd2b82f0e3f91ec2.tar.lz
gsoc2013-libgnome-autoar-40581a99721dd0079e7e183afd2b82f0e3f91ec2.tar.xz
gsoc2013-libgnome-autoar-40581a99721dd0079e7e183afd2b82f0e3f91ec2.tar.zst
gsoc2013-libgnome-autoar-40581a99721dd0079e7e183afd2b82f0e3f91ec2.zip
Fix segmentation fault when extracting archives using raw format
-rw-r--r--gnome-autoar/autoar-extract.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/gnome-autoar/autoar-extract.c b/gnome-autoar/autoar-extract.c
index 8fbf51d..315c855 100644
--- a/gnome-autoar/autoar-extract.c
+++ b/gnome-autoar/autoar-extract.c
@@ -1718,7 +1718,8 @@ autoar_extract_step_initialize_pattern (AutoarExtract *arextract) {
}
static void
-autoar_extract_step_scan_toplevel (AutoarExtract *arextract) {
+autoar_extract_step_scan_toplevel (AutoarExtract *arextract)
+{
/* Step 1: Scan all file names in the archive
* We have to check whether the archive contains a top-level directory
* before performing the extraction. We emit the "scanned" signal when
@@ -1740,19 +1741,19 @@ autoar_extract_step_scan_toplevel (AutoarExtract *arextract) {
if (r != ARCHIVE_OK) {
archive_read_free (a);
r = libarchive_create_read_object (TRUE, arextract, &a);
- if (priv->error == NULL) {
- if (r != ARCHIVE_OK) {
+ if (r != ARCHIVE_OK) {
+ if (priv->error == NULL)
priv->error = autoar_common_g_error_new_a (a, priv->source);
- } else if (archive_filter_count (a) <= 1){
- /* If we only use raw format and filter count is one, libarchive will
- * not do anything except for just copying the source file. We do not
- * want this thing to happen because it does unnecesssary copying. */
+ return;
+ } else if (archive_filter_count (a) <= 1){
+ /* If we only use raw format and filter count is one, libarchive will
+ * not do anything except for just copying the source file. We do not
+ * want this thing to happen because it does unnecesssary copying. */
+ if (priv->error == NULL)
priv->error = g_error_new (AUTOAR_EXTRACT_ERROR, NOT_AN_ARCHIVE_ERRNO,
"\'%s\': %s", priv->source, "not an archive");
- }
+ return;
}
- archive_read_free (a);
- return;
priv->use_raw_format = TRUE;
}