issue #3541 : Fix a bug when res is null.

Fix a bug when res is null.