diff --git a/src/common/sandbox.c b/src/common/sandbox.c
index 2f5859e7798d2548116be8a65cb99bdd5274a996..6fdddd2f2f55523d1964c671d7046492b3c2a6f0 100644
--- a/src/common/sandbox.c
+++ b/src/common/sandbox.c
@@ -830,7 +830,10 @@ prot_strings(sandbox_cfg_t* cfg)
       memcpy(pr_mem_next, param_val, param_size);
 
       // re-point el parameter to protected
-      free((char*)((smp_param_t*)el->param)->value);
+      {
+        void *old_val = ((smp_param_t*)el->param)->value;
+        tor_free(old_val);
+      }
       ((smp_param_t*)el->param)->value = (intptr_t) pr_mem_next;
       ((smp_param_t*)el->param)->prot = 1;