Fix null terminator in sdb_encode