Re #9017. Check for empty vector.
Re #9017. Added a test case to test the fix.
Merge branch 'bugfix/9017_extractmasktotable_bug' into develop