{"record":{"id":"bb2ede7982b0d5e0","repo":"gibbed/SteamAchievementManager","slug":"data","errorCode":null,"errorMessage":"data","messagePattern":"data","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"SAM.API/Wrappers/SteamUtils005.cs","lineNumber":73,"sourceCode":"        private delegate bool NativeGetImageSize(IntPtr self, int index, out int width, out int height);\n\n        public bool GetImageSize(int index, out int width, out int height)\n        {\n            var call = this.GetFunction<NativeGetImageSize>(this.Functions.GetImageSize);\n            return call(this.ObjectAddress, index, out width, out height);\n        }\n        #endregion\n\n        #region GetImageRGBA\n        [UnmanagedFunctionPointer(CallingConvention.ThisCall)]\n        [return: MarshalAs(UnmanagedType.I1)]\n        private delegate bool NativeGetImageRGBA(IntPtr self, int index, byte[] buffer, int length);\n\n        public bool GetImageRGBA(int index, byte[] data)\n        {\n            if (data == null)\n            {\n                throw new ArgumentNullException(\"data\");\n            }\n            var call = this.GetFunction<NativeGetImageRGBA>(this.Functions.GetImageRGBA);\n            return call(this.ObjectAddress, index, data, data.Length);\n        }\n        #endregion\n\n        #region GetAppID\n        [UnmanagedFunctionPointer(CallingConvention.ThisCall)]\n        private delegate uint NativeGetAppId(IntPtr self);\n\n        public uint GetAppId()\n        {\n            return this.Call<uint, NativeGetAppId>(this.Functions.GetAppID, this.ObjectAddress);\n        }\n        #endregion\n    }\n}\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/gibbed/SteamAchievementManager/blob/de8b71048a0cee3c3e97cd8535e0f55ca86513e4/SAM.API/Wrappers/SteamUtils005.cs#L55-L91","documentation":"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.","triggerScenarios":"Calling GetImageRGBA(index, data) with data == null, typically because the caller skipped querying the image size (GetImageSize) and allocating the array.","commonSituations":"Copying sample code without the size-query step; passing an uninitialized field; caching the buffer lazily and forgetting the first allocation.","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"],"exampleFix":"// before\nutils.GetImageRGBA(index, null);\n// after\nutils.GetImageSize(index, out var w, out var h);\nvar data = new byte[w * h * 4];\nutils.GetImageRGBA(index, data);","handlingStrategy":"validation","validationCode":"if (data == null) { utils.GetImageSize(index, out var w, out var h); data = new byte[w * h * 4]; }","typeGuard":"static bool IsValidImageBuffer(byte[] data) => data is { Length: > 0 };","tryCatchPattern":"try { utils.GetImageRGBA(index, data); }\ncatch (ArgumentNullException)\n{\n    // allocate correctly-sized buffer and retry\n}","preventionTips":["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"],"tags":["argument-null","steam","buffer"],"backgroundTag":"null-argument","analyzedSha":"de8b71048a0cee3c3e97cd8535e0f55ca86513e4","analyzedAt":"2026-09-12T09:05:06.619Z","contentChangedAt":"2026-09-12T09:05:06.619Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}