sd: fix STL assertion "dereference past-the-end iterator"

(regression from 967a386bccb15b99915a1e878e42450fbe9a2d0e)

Change-Id: I9408170eb155f433922e5b3887059078a141d78a
(cherry picked from commit 9632045906baf165076d11a97f45b153d8e2acb7)