In sl_reg_head you're going to want to free(password). Also, you want strlen(passkey) not sizeof(passkey). Even if you did that, you are still adding password to s1_newbuf not passkey.. which is what you attempted to allocate enough memory for. You need to malloc an additional four bytes not three, because of the trailing \0.
In sl_reg_tail you need to free(passkey).