EllanJiang/GameFramework · error · GameFrameworkException
Bytes is invalid.
Error message
Bytes is invalid.
What it means
Utility.Verifier.GetCrc32(byte[]) computes a CRC32 over an entire byte array. It throws GameFrameworkException("Bytes is invalid.") when the byte array argument is null, before delegating to the offset/length overload. This is a guard so callers get a clear framework exception instead of a NullReferenceException.
Solutions
- Null-check the byte array before calling GetCrc32
- Fix the upstream loader so it never yields a null buffer (throw or retry there instead)
- Catch GameFrameworkException and treat it as a checksum-computation failure
Example fix
// before int crc = Utility.Verifier.GetCrc32(data); // data may be null // after int crc = data != null ? Utility.Verifier.GetCrc32(data) : 0;
Defensive patterns
Strategy: type-guard
Validate before calling
if (bytes == null) { Log.Warning("Cannot CRC null buffer"); return 0; } Type guard
static bool IsValidBuffer(byte[] bytes) => bytes != null;
Try / catch
try { return Utility.Verifier.GetCrc32(bytes); }
catch (GameFrameworkException ex) { Log.Warning("CRC failed: {0}", ex.Message); return 0; } Prevention
- Check loader results for null before checksum steps
- Make load failures throw instead of returning null buffers
- Guard checksum helpers behind non-null wrappers
When it happens
Trigger: Calling Utility.Verifier.GetCrc32(bytes) with a null byte[] — e.g. a file read that failed and returned null, or an uninitialized download buffer.
Common situations: Computing a checksum of a resource whose bytes failed to load; passing the result of a failed AssetBundle/WebRequest read; pipeline stage dropping a buffer on error without propagating it.
Related errors
- Stream is invalid.
- Result is invalid.
- Offset or length is invalid.
- Code is invalid.
- Resource manager is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/d6962a51550cbcc7.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Utility/Utility.Verifier.cs:33
/// <summary>
/// 校验相关的实用函数。
/// </summary>
public static partial class Verifier
{
private const int CachedBytesLength = 0x1000;
private static readonly byte[] s_CachedBytes = new byte[CachedBytesLength];
private static readonly Crc32 s_Algorithm = new Crc32();
/// <summary>
/// 计算二进制流的 CRC32。
/// </summary>
/// <param name="bytes">指定的二进制流。</param>
/// <returns>计算后的 CRC32。</returns>
public static int GetCrc32(byte[] bytes)
{
if (bytes == null)
{
throw new GameFrameworkException("Bytes is invalid.");
}
return GetCrc32(bytes, 0, bytes.Length);
}
/// <summary>
/// 计算二进制流的 CRC32。
/// </summary>
/// <param name="bytes">指定的二进制流。</param>
/// <param name="offset">二进制流的偏移。</param>
/// <param name="length">二进制流的长度。</param>
/// <returns>计算后的 CRC32。</returns>
public static int GetCrc32(byte[] bytes, int offset, int length)
{
if (bytes == null)
{
throw new GameFrameworkException("Bytes is invalid.");
}View on GitHub (pinned to d0c010b051)