xml.ui: Bug 495415: Safely absolute a hashcode
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 3 Jun 2016 14:55:48 +0000 (10:55 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 3 Jun 2016 20:56:37 +0000 (16:56 -0400)
commit8b0730f435890afe5ad6a61a1880d963ce8d7705
tree41fad31dd1d83de38fe5a8fc97db953033f3398a
parentd8771bb6ad13cf5e4d405e9057f5375499d02cfb
xml.ui: Bug 495415: Safely absolute a hashcode

It is possible for a call to hashCode to return
Integer.MIN_VALUE. Take the absolute value of such
a hashcode and you'll still have a negative number.
Since your code is likely to assume that it's a
positive value instead, your results will be unreliable.

Similarly, Integer.MIN_VALUE could be returned from
Random.nextInt() or any object's compareTo method,
and Long.MIN_VALUE could be returned from Random.nextLong().
Calling Math.abs on values returned from these methods
is similarly ill-advised.

Change-Id: I44396a35d3efd046b8a082ebb57c070387d9f90d
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/74533
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java
This page took 0.024635 seconds and 5 git commands to generate.