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