IANAL and this is not legal advice, but this may be illegal depending on the labor laws of the state you work in. I work in California and my employer provided this nice little tidbit from California Labor Code 2870 when I signed my contract (http://www.leginfo.ca.gov/cgi-bin/displaycode?section=lab&group=02001-03000&file=2870-2872) :
"(a) Any provision in an employment agreement which provides that an employee shall assign, or offer to assign, any of his or her rights in an invention to his or her employer shall not apply to an invention that the employee developed entirely on his or her own time without using the employer’s equipment, supplies, facilities, or trade secret information except for those inventions that either:
(1) Relate at the time of conception or reduction to practice of the invention to the employer’s business, or actual or demonstrably anticipated research or development of the employer.
(2) Result from any work performed by the employee for the employer.
(b) To the extent a provision in an employment agreement purports to require an employee to assign an invention otherwise excluded from being required to be assigned under subdivision (a), the provision is against the public policy of this state and is unenforceable.”
The "relate at the time of conception or reduction ..." clause may bite you depending on when you developed the free software and how broad a judge's interpretation of your employer's business is, but a law like this in your state may give you some wiggle room out of a nasty contract. Good luck.