Closed GoogleCodeExporter closed 9 years ago
It is already checked if an error function is defined. If you use the default
constructor, the error function will never be called. You think that is not
enough?
Look at line 34 of MeetAndroid.cpp
if (customErrorFunc)
errorFunc(buffer[0], getArrayLength());
else {
Serial.print("No func. attached for: ");
Serial.print(buffer[0]);
}
Original comment by bonifaz....@gmail.com
on 26 Oct 2010 at 9:32
I don't think so because that check is only done if flag is out the allowable
bounds of the intFunc subscript. If the flag is in bounds (which is usually the
case), then the function pointer is extracted from the array and executed. By
default, the intFunc array is initialized with the 'errorFunc' function pointer
variable. If the 'errorFunc' is not set then it is pointing to arbitrary
memory; which is the case when the default constructor is used.
For example,
1. Initialize with default constructor
2. Register for flag 'b'
3. Execute receive in loop()
4. Incoming Bytes -> ['f', 12, 59]
5. Delegate to Process Command
6. Subscript Bounds Check -> OK ( (102 - 48) < 75)
7. Extract Function Pointer -> intFunc[102 - 48]
8. Execute Function -> errorFunc is unset which would cause undefined behavior
Original comment by dewi...@gmail.com
on 26 Oct 2010 at 9:53
Oh yes you are right.
Would you correct the library and attach the new corrected files to this issue.
I will then commit your changes.
Original comment by bonifaz....@gmail.com
on 26 Oct 2010 at 10:24
I would really appreciate it.
Original comment by bonifaz....@gmail.com
on 26 Oct 2010 at 10:25
ok I did it already...fixed another little bug as well...will commit the code
in a few minutes.
Original comment by bonifaz....@gmail.com
on 26 Oct 2010 at 10:37
Original comment by bonifaz....@gmail.com
on 26 Oct 2010 at 10:38
Thanks!
Original comment by dewi...@gmail.com
on 26 Oct 2010 at 10:41
Original issue reported on code.google.com by
dewi...@gmail.com
on 25 Oct 2010 at 11:30