bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: segfault in parted.c, inconsistency in 1.6.6


From: Michael Schwendt
Subject: Re: segfault in parted.c, inconsistency in 1.6.6
Date: Thu, 16 Oct 2003 11:12:43 +0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 16 Oct 2003 12:53:16 +1000, Andrew Clausen wrote:

> > However, the line that was moved in the do_mkpart() function in the
> > parted.c file is found at a different place compared with the
> > do_mkpartfs() function that follows. Which one is right?
> > 
> > In do_mkpart(), the call to ped_constraint_destroy(..) is done later
> > than in do_mkpartfs(). 
> > 
> > I'm not familiar with the code, but with the several goto's it can
> > happen that in do_mkpart() it is returned from the function without
> > calling ped_constraint_destroy(..) compared with do_mkpartfs().
> 
> I disagree (convince me!)

Let's see. The following is from parted 1.6.6. There are two goto
error_destroy_disk before the constraint destruction. When either
branch is taken due to errors, the constraint is not destroyed.

do_mkpart()
    /* ... */
    
        if (!ped_partition_set_system (part, fs_type))
                goto error_destroy_disk;                    /* ! */
        if (!ped_disk_commit (disk))
                goto error_destroy_disk;                    /* ! */
        ped_constraint_destroy (constraint);
        ped_disk_destroy (disk);
        return 1;

    /* ... */

error_destroy_disk:
        ped_disk_destroy (disk);
error:
        return 0;
}


On the contrary, in do_mkpartfs(), the constraint destruction comes
earlier.

do_mkpartfs()
    /* ... */

        ped_constraint_destroy (constraint);            /* ! */

        if (!ped_partition_set_system (part, fs_type))
                goto error_destroy_disk;

        if (!ped_disk_commit (disk))
                goto error_destroy_disk;
        ped_disk_destroy (disk);
        return 1;

    /* ... */

error_destroy_disk:
        ped_disk_destroy (disk);
error:
        return 0;
}


Just curious, as to fix the segfault in parted 1.6.3, I had to move
the constraint destruction in do_mkpart().

- -- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/jmEL0iMVcrivHFQRAltXAJ44Allb6IiDqRDy1arAmcNIFCrK1QCfeItR
/tgxEDMZXwpipEfH7Y1vIC4=
=ZIEA
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]