Skip to content

Commit

Permalink
Fix two defects found by Coverity
Browse files Browse the repository at this point in the history
  • Loading branch information
c-rack committed May 20, 2015
1 parent 039201e commit c6c48f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/java/co/nstant/in/cbor/builder/AbstractBuilder.java
Expand Up @@ -92,7 +92,9 @@ private boolean isHalfPrecisionEnough(float value) {
byte[] bytes = outputStream.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
HalfPrecisionFloatDecoder decoder = getHalfPrecisionFloatDecoder(inputStream);
inputStream.read(); // to skip type byte
if (inputStream.read() == -1) { // to skip type byte
throw new CborException("unexpected end of stream");
}
HalfPrecisionFloat halfPrecisionFloat = decoder.decode(0);
return value == halfPrecisionFloat.getValue();
} catch (CborException cborException) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/co/nstant/in/cbor/model/AbstractFloat.java
Expand Up @@ -26,7 +26,7 @@ public boolean equals(Object object) {

@Override
public int hashCode() {
return Objects.hashCode(value);
return super.hashCode() ^ Objects.hashCode(value);
}

}

0 comments on commit c6c48f5

Please sign in to comment.