script: Fix reference into empty vector run time exception

Edit by laanwj: `begin_ptr(sourcedata) + sourcedata.size()` -> `end_ptr(sourcedata)`
Merge pull request #4968

219372f script: Fix reference into empty vector run time exception (ENikS)