diff options
author | Petr Mrázek <peterix@gmail.com> | 2018-02-11 01:21:32 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2018-02-11 01:21:32 +0100 |
commit | 604295e6d504f6e41ec2f91500479edbf2838a2d (patch) | |
tree | 57ddc6da407799994c30a8f984c0e92976d8e02f /libraries | |
parent | f259e9f72734158df90c93ae7cdda87489d7bfaf (diff) | |
download | MultiMC-604295e6d504f6e41ec2f91500479edbf2838a2d.tar MultiMC-604295e6d504f6e41ec2f91500479edbf2838a2d.tar.gz MultiMC-604295e6d504f6e41ec2f91500479edbf2838a2d.tar.lz MultiMC-604295e6d504f6e41ec2f91500479edbf2838a2d.tar.xz MultiMC-604295e6d504f6e41ec2f91500479edbf2838a2d.zip |
NOISSUE fix some warnings
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/classparser/src/annotations.h | 1 | ||||
-rw-r--r-- | libraries/classparser/src/constants.h | 16 |
2 files changed, 10 insertions, 7 deletions
diff --git a/libraries/classparser/src/annotations.h b/libraries/classparser/src/annotations.h index aa25d241..dd603af3 100644 --- a/libraries/classparser/src/annotations.h +++ b/libraries/classparser/src/annotations.h @@ -42,6 +42,7 @@ protected: public: element_value(element_value_type type, constant_pool &pool) : type(type), pool(pool) {}; + virtual ~element_value() {} element_value_type getElementValueType() { diff --git a/libraries/classparser/src/constants.h b/libraries/classparser/src/constants.h index 242b943e..9c74ab20 100644 --- a/libraries/classparser/src/constants.h +++ b/libraries/classparser/src/constants.h @@ -21,14 +21,12 @@ public: j_methodref = 10, j_interface_methodref = 11, j_nameandtype = 12 + // FIXME: missing some constant types, see https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4 } type; constant(util::membuffer &buf) { buf.read(type); - // invalid constant type! - if (type > j_nameandtype || type == (type_t)0 || type == (type_t)2) - throw new classfile_exception(); // load data depending on type switch (type) @@ -65,10 +63,13 @@ public: buf.read_be(name_and_type.name_index); buf.read_be(name_and_type.descriptor_index); break; + default: + // invalid constant type! + throw new classfile_exception(); } } - constant(int fake) + constant(int) { type = j_hole; } @@ -115,6 +116,9 @@ public: ss << "NameAndType: " << name_and_type.name_index << " " << name_and_type.descriptor_index; break; + default: + ss << "Invalid entry (" << int(type) << ")"; + break; } return ss.str(); } @@ -166,10 +170,10 @@ public: */ void load(util::membuffer &buf) { + // FIXME: @SANITY this should check for the end of buffer. uint16_t length = 0; buf.read_be(length); length--; - uint16_t index = 1; const constant *last_constant = nullptr; while (length) { @@ -182,12 +186,10 @@ public: // push in a fake constant to preserve indexing constants.push_back(constant(0)); length -= 2; - index += 2; } else { length--; - index++; } } } |