Fixed a crash caused by autoreleasing NSError object inside the method t...

...hat was supposed to be passed to the caller by reference using method's argument.

The crash is described in issue #1885. Removing the `@autoreleasepool` is an option as well but this PR fixes memory management only without changing when autoreleased objects are being released - except the `error` object.