fix argument with 'nonnull' attribute passed null
fixes for memory leaks