Home GnuPG

Allow using gpgrt_lock_init on an unitialized variable.
4e8a88e7632bUnpublished

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Allow using gpgrt_lock_init on an unitialized variable.

* src/posix-lock.c (gpgrt_lock_init): Detect unitialized lock var.
* src/w32-lock.c (gpgrt_lock_init): Ditto.

gpgrt_lock_init may be used for dynamically allocated locks. For
example

gpgrt_lock_t *lock = xcalloc (1, sizeof *lock);
gpgrt_lock_init (lock);
gpgrt_lock_lock (lock);
foo ();
gpgrt_lock_unlock (lock);
gpgrt_lock_destroy (lock);
free (lock);

This patch actually allows for this.

  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Provenance
wernerAuthored on Jan 9 2014, 7:14 PM
Parents
rEe07538c0ed3c: Move version number first in the Posix lock-obj.
Branches
Unknown
Tags
Unknown

Event Timeline

Werner Koch <wk@gnupg.org> committed rE4e8a88e7632b: Allow using gpgrt_lock_init on an unitialized variable. (authored by Werner Koch <wk@gnupg.org>).Jan 24 2014, 4:29 PM