gibbed/SteamAchievementManager · error · ArgumentNullException
data
Error message
data
What it means
Wrappers.SteamUtils005.GetImageRGBA throws ArgumentNullException (message "data") when the caller passes a null byte[] buffer. The method needs a pre-allocated buffer of the image's size to fill via the native GetImageRGBA call; null means no destination was provided.
Solutions
- Query the image dimensions and allocate a byte[w*h*4] buffer before calling GetImageRGBA
- Guard against null before calling, or ensure the buffer field is initialized
- Reuse a cached correctly-sized buffer per image index
Example fix
// before utils.GetImageRGBA(index, null); // after utils.GetImageSize(index, out var w, out var h); var data = new byte[w * h * 4]; utils.GetImageRGBA(index, data);
Defensive patterns
Strategy: validation
Validate before calling
if (data == null) { utils.GetImageSize(index, out var w, out var h); data = new byte[w * h * 4]; } Type guard
static bool IsValidImageBuffer(byte[] data) => data is { Length: > 0 }; Try / catch
try { utils.GetImageRGBA(index, data); }
catch (ArgumentNullException)
{
// allocate correctly-sized buffer and retry
} Prevention
- Always call GetImageSize and allocate byte[w*h*4] before GetImageRGBA
- Never pass unassigned arrays; initialize buffer fields at declaration
- Validate buffers with a null/length check before native calls
When it happens
Trigger: Calling GetImageRGBA(index, data) with data == null, typically because the caller skipped querying the image size (GetImageSize) and allocating the array.
Common situations: Copying sample code without the size-query step; passing an uninitialized field; caching the buffer lazily and forgetting the first allocation.
Related errors
- failed to get Steam install path
- failed to load SteamClient
- failed to create ISteamClient018
- failed to create pipe
- failed to connect to global user
AI-assisted analysis of gibbed/SteamAchievementManager@de8b71048a (2026-09-12).
Data as JSON: /api/errors/bb2ede7982b0d5e0.
Report an issue: GitHub.
Appendix: source
Thrown at SAM.API/Wrappers/SteamUtils005.cs:73
private delegate bool NativeGetImageSize(IntPtr self, int index, out int width, out int height);
public bool GetImageSize(int index, out int width, out int height)
{
var call = this.GetFunction<NativeGetImageSize>(this.Functions.GetImageSize);
return call(this.ObjectAddress, index, out width, out height);
}
#endregion
#region GetImageRGBA
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
[return: MarshalAs(UnmanagedType.I1)]
private delegate bool NativeGetImageRGBA(IntPtr self, int index, byte[] buffer, int length);
public bool GetImageRGBA(int index, byte[] data)
{
if (data == null)
{
throw new ArgumentNullException("data");
}
var call = this.GetFunction<NativeGetImageRGBA>(this.Functions.GetImageRGBA);
return call(this.ObjectAddress, index, data, data.Length);
}
#endregion
#region GetAppID
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate uint NativeGetAppId(IntPtr self);
public uint GetAppId()
{
return this.Call<uint, NativeGetAppId>(this.Functions.GetAppID, this.ObjectAddress);
}
#endregion
}
}
View on GitHub (pinned to de8b71048a)