I know a guy who got into trouble write a <insert favorite programming language> module and putting it in a public repository. The module solved the current task. It was easy to install and had documentation. All good? No. The company claimed he spent extra (meaning unnecessary time) cleaning up the code and making is usable for other companies. Also I think he didn't attribute the company. They claimed full copyright to the module, co-maintainer status and reimbursement (money back from the outsourcing company, not sure if they could have deducted part of the salary).
To be save I would even suggest to invest in a second laptop so the company can't claim you used company resources at home after work.