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