Skip to content

TClasses throws Exception #1

Description

@LokiMidgard

The Constructor throws a lot of Exceptions.

I think the Problem is that the if always returns true. If Common.ReadWord(Reader) returns 0, this Value will be decremented by one. That leads to the maximum value of Uint. That is greater than 0.

      public TClasses(BinaryReader Reader, TConstantPool ConstantPool)
        {
            InnerClassInfoIndex = 0;
            InnerClassInfo = null;
            OuterClassInfoIndex = 0;
            ;
            OuterClassInfo = null;
            InnerNameIndex = 0;
            ;
            InnerName = null;
            InnerClassAccessFlags = 0;
            ;

            try
            {
                InnerClassInfoIndex = Common.ReadWord(Reader);
                InnerClassInfoIndex--;
                OuterClassInfoIndex = Common.ReadWord(Reader);
                OuterClassInfoIndex--;
                InnerNameIndex = Common.ReadWord(Reader);
                InnerNameIndex--;
                InnerClassAccessFlags = Common.ReadWord(Reader);

                // resolve references
                if (InnerNameIndex >= 0) // Always true because ushort has no value below 0
                {
                    InnerName = (ConstantUtf8Info)ConstantPool.Item(InnerNameIndex);
                    InnerName.References++; // Check for Null to avoid Exceptions
                }
                if (InnerNameIndex >= 0) // Always true because ushort has no value below 0
                {
                    InnerClassInfo = (ConstantClassInfo)ConstantPool.Item(InnerClassInfoIndex);
                    InnerClassInfo.References++;// Check for Null to avoid Exceptions
                }
                if (InnerNameIndex >= 0) // Always true because ushort has no value below 0
                {
                    OuterClassInfo = (ConstantClassInfo)ConstantPool.Item(OuterClassInfoIndex);
                    OuterClassInfo.References++;// Check for Null to avoid Exceptions
                }
            }
            catch (Exception e)
            {
                // do nothing
            }
        }

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions