Fix wrong checking of returned descriptor type