summaryrefslogtreecommitdiff
path: root/libfshelp
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-10-09 23:38:50 +0200
committerJustus Winter <justus@gnupg.org>2017-09-12 10:41:35 +0200
commit47715139bb7bc8e2c94536a34207e0028a7f65b4 (patch)
tree37a8d9a913a08ed2ef43f9ab1c9348d21e11c457 /libfshelp
parent074f0ea9799b2fa5297eb120d68e0a97cf1b40ac (diff)
libfshelp: Improve error handling.
* libfshelp/translator-list.c (fshelp_set_active_translator): Free resources. Assert that an entry is removed. (fshelp_remove_active_translator): Assert that an entry is removed.
Diffstat (limited to 'libfshelp')
-rw-r--r--libfshelp/translator-list.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/libfshelp/translator-list.c b/libfshelp/translator-list.c
index c64e1747..91a2c342 100644
--- a/libfshelp/translator-list.c
+++ b/libfshelp/translator-list.c
@@ -20,6 +20,7 @@
along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
#include <argz.h>
+#include <assert-backtrace.h>
#include <hurd/fsys.h>
#include <hurd/ihash.h>
#include <hurd/ports.h>
@@ -113,7 +114,11 @@ fshelp_set_active_translator (struct port_info *pi,
err = hurd_ihash_locp_add (&translator_ihash, slot,
(hurd_ihash_key_t) t->name, t);
if (err)
- goto out;
+ {
+ free (t->name);
+ free (t);
+ goto out;
+ }
update:
if (MACH_PORT_VALID (active))
@@ -142,7 +147,11 @@ fshelp_set_active_translator (struct port_info *pi,
t->active = active;
}
else
- hurd_ihash_remove (&translator_ihash, (hurd_ihash_key_t) t);
+ {
+ int ok;
+ ok = hurd_ihash_remove (&translator_ihash, (hurd_ihash_key_t) t->name);
+ assert_backtrace (ok);
+ }
out:
pthread_mutex_unlock (&translator_ihash_lock);
@@ -170,7 +179,11 @@ fshelp_remove_active_translator (mach_port_t active)
}
if (t)
- hurd_ihash_remove (&translator_ihash, (hurd_ihash_key_t) t->name);
+ {
+ int ok;
+ ok = hurd_ihash_remove (&translator_ihash, (hurd_ihash_key_t) t->name);
+ assert_backtrace (ok);
+ }
pthread_mutex_unlock (&translator_ihash_lock);
return err;