Fix the last remaining CCritSect by checking error codes before they're
overwritten by unrelated implementation-defined code.