Make sure to unmap input buffer on errors.
Use "gsize" instead of "int".