MFC of 249789:

Fix error check.

Submitted by: Andrey Chernov (ache@)