Skip to content

Possible BUG in SingleArrayBufferAllocator.cs #287

Description

@gviolator
	private static byte[] Allocate( byte[] old, int requestSize )
		{
			if ( old.Length < 256 )
			{
				return new byte[ 256 ];
			}

			// Use golden ratio to improve linear memory range reusability (of LOH)
			var newSize = Math.Max( ( long )( old.Length * 1.1618 ), requestSize + ( long )old.Length );
			if ( newSize > Int32.MaxValue )
			{
				return null;
			}

			return new byte[ newSize ];
		}

May be instead of

if ( old.Length < 256 )

should be

if (requestSize  < 256 )

Because if requested buffer size is greater than 256 and current buffer's length is less than 256 (for example we just serialize big string), then we fail to allocate, and whole serialization process will fail ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugDetected as bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions