diff --git a/pd/src/g_text.c b/pd/src/g_text.c
index 81ff821d98105ccd3314358b78840daa235839c8..913fa75db82d752208722fce2d000601eca2c714 100644
--- a/pd/src/g_text.c
+++ b/pd/src/g_text.c
@@ -2354,6 +2354,7 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
                 //just retext it
                 t_rtext *yr = glist_findrtext(glist, x);
                 if (yr) rtext_retext(yr);
+                binbuf_free(b);
             }
         }
         else  /* normally, just destroy the old one and make a new one. */
@@ -2389,6 +2390,7 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
                 //fprintf(stderr,"just retext it\n");
                 t_rtext *yr = glist_findrtext(glist, x);
                 if (yr) rtext_retext(yr);
+                binbuf_free(b);
             }
         }
             /* if we made a new "pd" or changed a window name,