issue #3541 : Fix a bug when res is null.
Merge pull request #1390 from SmallAiTT/iss3541_4_testCase

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