AJCORE-1296 Fixed issues found using static analysis tool

- Fixed posible situations that a mutex lock could be locked
  but not unlocked.
- Add check to make sure iterators were not equal to end().
  In all cases the iterators should never be equal end() since
  the count was set using the min function. The extra check
  does not hurt.
- The post increment operator ++ has higher precedence than the
  the dereference operator *.  I think this confused the static
  analysis tool so I split the code to two lines.
- asserts are compiled out in release code so a return had to be
  added after the assert.

Change-Id: Ida1db1258a9260f23e65b3a9274290a2bebed10e
Signed-off-by: George Nash <georgen@qce.qualcomm.com>
Merge "AJCORE-1296 Fixed issues found using static analysis tool" into RB14.12