From dc9a1490885efeea0e3a5946f68651fe99ade2fc Mon Sep 17 00:00:00 2001
From: zesstra <zesstra@zesstra.de>
Date: Mon, 9 Mar 2009 19:58:36 +0100
Subject: [PATCH] Fixed freeing of the arguments of f_idna_stringprop().
 The stack pointer was decremented after getting the third argument.
 Converted free'ing of the second argument into stack pointer decrement.
 Added free'ing of the given string.
 Removed putting a return value on the stack in case of calling errorf.

---
 src/pkg-idna.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/pkg-idna.c b/src/pkg-idna.c
index c0ece1a..9bf7f4f 100644
--- a/src/pkg-idna.c
+++ b/src/pkg-idna.c
@@ -130,6 +130,7 @@ f_idna_stringprep (svalue_t *sp)
     /* Get and check the flags. */
     {
         p_uint argflags = (p_uint)sp->u.number;
+        sp--;
 
         if (argflags > (STRINGPREP_FLAG_MAX << 1)-1
          || argflags & (STRINGPREP_NO_NFKC_FLAG | STRINGPREP_NO_BIDI_FLAG)
@@ -148,7 +149,7 @@ f_idna_stringprep (svalue_t *sp)
 
     /* Get and check the profile */
     prof = (int)sp->u.number;
-    free_svalue(sp--);
+    sp--;
 
     /* select the profile */
     switch(prof)
@@ -206,12 +207,13 @@ f_idna_stringprep (svalue_t *sp)
 
     if (ret != STRINGPREP_OK)
     {
-        put_number(sp, -ret);
         errorf("stringprep(): Error %s", stringprep_strerror(ret));
         /* NOTREACHED */
-    } 
+    }
     else 
     {
+        // free the string argument
+        free_svalue(sp);
         put_c_string(sp, buf);
     }
 
-- 
1.6.1

