diff --git a/src/pike_types.c b/src/pike_types.c
index e07323709522fa946099635f1071cac050a2caeb..2cad46a45e042110fd15e3cad855fd8af0fb3a0e 100644
--- a/src/pike_types.c
+++ b/src/pike_types.c
@@ -5648,14 +5648,18 @@ struct pike_type *check_call(struct pike_type *args,
  */
 struct pike_type *get_argument_type(struct pike_type *fun, int arg_no)
 {
-  struct pike_type *tmp;
+  struct pike_type *tmp, *tmp2;
 
  loop:
   switch(fun->type) {
   case T_OR:
-    return or_pike_types(get_argument_type(fun->car, arg_no),
-			 get_argument_type(fun->cdr, arg_no),
-			 1);
+    fun = or_pike_types(tmp = get_argument_type(fun->car, arg_no),
+			tmp2 = get_argument_type(fun->cdr, arg_no),
+			1);
+    free_type(tmp);
+    free_type(tmp2);
+    return fun;
+
   case T_FUNCTION:
     if (arg_no > 0) {
       arg_no--;