From 24ad08b9ad5d781be0c844590df250d9e6183ade Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 30 Aug 2006 12:23:01 +0000 Subject: [PATCH] Repaired SIGSEGV caused by releasing ungrabbed drive after mere bus scan --- test/burniso.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/burniso.c b/test/burniso.c index 111769b..31bff57 100644 --- a/test/burniso.c +++ b/test/burniso.c @@ -68,6 +68,10 @@ static struct burn_drive_info *drives; friendly to the users of other drives on those systems. Beware. */ static unsigned int n_drives; +/** This variable indicates wether the drive is grabbed and must be + finally released */ +static int drive_is_grabbed = 0; + /** Wether to burn for real or to *try* to simulate a burn */ static int simulate_burn = Burniso_try_to_simulatE ; @@ -119,8 +123,10 @@ int burn_app_aquire_by_adr(char *drive_adr) ret = burn_drive_scan_and_grab(&drives,drive_adr,1); if (ret <= 0) printf("Failed\n"); - else + else { printf("done\n"); + drive_is_grabbed = 1; + } return ret; } @@ -295,11 +301,14 @@ int burn_app_regrab(struct burn_drive *drive) { int ret; printf("Releasing and regrabbing drive ...\n"); - burn_drive_release(drive, 0); + if (drive_is_grabbed) + burn_drive_release(drive, 0); + drive_is_grabbed = 0; ret = burn_drive_grab(drive, 0); - if (ret != 0) + if (ret != 0) { + drive_is_grabbed = 1; printf("done\n"); - else + } else printf("Failed\n"); return !!ret; } @@ -568,7 +577,8 @@ int main(int argc, char **argv) } ret = 0; release_drive:; - burn_drive_release(drives[driveno].drive, 0); + if(drive_is_grabbed) + burn_drive_release(drives[driveno].drive, 0); finish_libburn:; /* This app does not bother to know about exact scan state.