=== trunk/parted/ui.c #! /bin/sh -e ## fix_rescue_segfault.dpatch by Otavio Salvador ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Fix a segfault in recue command. Backported from 1.6.26 . `dirname $0`/DPATCH @DPATCH@ ================================================================== --- trunk/parted/ui.c (revision 321) +++ trunk/parted/ui.c (revision 322) @@ -559,18 +559,21 @@ * default. */ if (input && *value && !strcmp (input, def_str)) { - *range = ped_geometry_new (dev, *value, 1); - PED_ASSERT (*range != NULL, return 0); + if (range) { + *range = ped_geometry_new (dev, *value, 1); + ped_free (def_str); + return *range != NULL; + } ped_free (def_str); - return 1; } ped_free (def_str); if (!input) { *value = 0; - *range = NULL; + if (range) + *range = NULL; return 0; } === trunk/libparted/unit.c ================================================================== --- trunk/libparted/unit.c (revision 321) +++ trunk/libparted/unit.c (revision 322) @@ -352,15 +352,17 @@ str, dev->path); goto error_free_copy; } - *range = ped_geometry_new (dev, *sector, 1); + if (range) + *range = ped_geometry_new (dev, *sector, 1); ped_free (copy); - return 1; + return !range || *range != NULL; error_free_copy: ped_free (copy); error: *sector = 0; - *range = NULL; + if (range) + *range = NULL; return 0; } @@ -455,26 +457,28 @@ /* negative numbers count from the end */ if (copy[0] == '-') *sector += dev->length; - *range = geometry_from_centre_radius (dev, *sector, radius); - if (!*range) { - ped_exception_throw ( - PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, - _("The location %s is outside of the device %s."), - str, dev->path); - goto error_free_copy; + if (range) { + *range = geometry_from_centre_radius (dev, *sector, radius); + if (!*range) { + ped_exception_throw ( + PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, + _("The location %s is outside of the " + "device %s."), + str, dev->path); + goto error_free_copy; + } } *sector = clip (dev, *sector); ped_free (copy); return 1; -error_destroy_range: - ped_geometry_destroy (*range); error_free_copy: ped_free (copy); error: *sector = 0; - *range = NULL; + if (range) + *range = NULL; return 0; }