{"record":{"id":"e23670c4a656488e","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-objectpoolmanager-objectpool","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/ObjectPool/ObjectPoolManager.ObjectPool.cs","lineNumber":581,"sourceCode":"                if (target == null)\n                {\n                    throw new GameFrameworkException(\"Target is invalid.\");\n                }\n\n                Object<T> internalObject = null;\n                if (m_ObjectMap.TryGetValue(target, out internalObject))\n                {\n                    return internalObject;\n                }\n\n                return null;\n            }\n\n            private void GetCanReleaseObjects(List<T> results)\n            {\n                if (results == null)\n                {\n                    throw new GameFrameworkException(\"Results is invalid.\");\n                }\n\n                results.Clear();\n                foreach (KeyValuePair<object, Object<T>> objectInMap in m_ObjectMap)\n                {\n                    Object<T> internalObject = objectInMap.Value;\n                    if (internalObject.IsInUse || internalObject.Locked || !internalObject.CustomCanReleaseFlag)\n                    {\n                        continue;\n                    }\n\n                    results.Add(internalObject.Peek());\n                }\n            }\n\n            private List<T> DefaultReleaseObjectFilterCallback(List<T> candidateObjects, int toReleaseCount, DateTime expireTime)\n            {\n                m_CachedToReleaseObjects.Clear();","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/ObjectPool/ObjectPoolManager.ObjectPool.cs#L563-L599","documentation":"GetCanReleaseObjects fills a caller-provided List<T> with objects eligible for release. A null list cannot be filled, so the pool throws 'Results is invalid.' The list is reused by CanReleaseCount, Release(count, filter) and ReleaseAllUnused to avoid allocations.","triggerScenarios":"Internal call paths passing a non-initialized list — practically triggered if subclass/modified code overrides or invokes this private helper with null, or custom builds call it directly.","commonSituations":"Custom forks of GameFramework extending ObjectPool with their own release logic; reflection-based tooling invoking private methods with incomplete arguments.","solutions":["Always construct and pass a valid List<T> instance (it may be empty; it is cleared first).","In custom code, prefer the public Release/CanReleaseCount APIs which allocate the list correctly.","If maintaining a fork, add lazy initialization: results ??= new List<T>()."],"exampleFix":"// before\nList<T> results = null;\nGetCanReleaseObjects(results);\n// after\nList<T> results = new List<T>();\nGetCanReleaseObjects(results);","handlingStrategy":"validation","validationCode":"var results = new List<T>();\nif (results != null)\n{\n    GetCanReleaseObjects(results);\n}","typeGuard":null,"tryCatchPattern":"try { GetCanReleaseObjects(results); }\ncatch (GameFrameworkException) { /* results list was null; allocate and retry */ }","preventionTips":["Always allocate the results list before invoking the helper.","Prefer public Release/CanReleaseCount APIs over private internals.","In forks, lazy-initialize list parameters."],"tags":["gameframework","objectpool","null-argument","internal"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}