"This is why you need to keep strings and userdata on the stack until you're completely done working with them - so that lua doesn't free them." Thank you that answers my question and makes it clear what is required. Liam