Closed Bug 760347 Opened 12 years ago Closed 12 years ago

nsDeviceSensor.cpp ASSERTs in debug builds for light sensors

Categories

(Core :: DOM: Device Interfaces, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla16

People

(Reporter: dhylands, Assigned: dhylands)

Details

Attachments

(1 file, 1 obsolete file)

I'm hitting the following assert in B2G on debug builds:
Assertion failure: i < Length() (invalid array index), at ../../dist/include/nsTArray.h:535

This appears to be occuring with light sensors which only have a single value. The nsDeviceSensors::Notify function blindly pulls 3 values which causes the assert.
Component: Hardware Abstraction Layer (HAL) → DOM: Device Interfaces
QA Contact: hal → device-interfaces
Attachment #629033 - Flags: review?(doug.turner)
I would do

 const InfallibleTArray<float>& values = aSensorData.values();
 size_t len = values.Length();
 double x = len > 0 ? values[0] : 0.0;
 double y = len > 1 ? values[1] : 0.0;
 //...
Bah. Humbug.

OK - I like the looks of your version better.
Attachment #629033 - Attachment is obsolete: true
Attachment #629033 - Flags: review?(doug.turner)
Attachment #629041 - Flags: review?(doug.turner)
Attachment #629041 - Flags: review?(doug.turner) → review+
Whiteboard: need
Whiteboard: need → checkin-needed
Assignee: nobody → dhylands
https://hg.mozilla.org/mozilla-central/rev/3524b3fe9492
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla16
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: