Skip to content

bug: user-provided value modification during read operations #79

Description

@jacoscaz

The following line alters an object that, in some cases, is passed to the library by the user without any expectation that the object might be modified.

value.type = ApplicationTag.NULL

However, I do understand why this is being done, which is to ensure consistency for NULL values. I think replacing that block with a conditional assertion would work much better and make for more informative error messages. Basically, I would suggest going from this:

	if (value.value === null) {
		value.type = ApplicationTag.NULL
	}

To this:

        if (value.type === ApplicationTag.NULL) {
                  assert(value.value === null, 'inconsistent value object, type is ApplicationTag.NULL but value is not null');
        }

I stumbled into this because, for performance reasons, I pre-allocate an array of frozen ApplicationTag.NULL values to populate PRIORITY_ARRAY and reading such property network-side (without writing to it!) resulted in this error:

TypeError: Cannot assign to read only property 'type' of object '#<Object>'

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions