Everybody has experienced the bad boss once or twice in their life.
My bad boss was on one of my early programming jobs right out of college. She was the classic incompetent manager with a side of egocentric thrown in. I'd get done writing a program or report and verified it worked the way it was supposed to. I would then put the program into production and let the users verify the report worked exactly as expected.
Unbeknown to me, my boss would "fix" my code in the middle of the night and put it into production without even testing it. Of course, I got a call in the morning saying my code dumped core or broke the morning build. I couldn't understand it. That's when I started learning about diff, checksum, and about Sun auditing. I told another manager what I found and sure enough, this wasn't the first time.
I dealt with it mostly with CYA until I could get out.