Jacek Caban (@jacek) commented about dlls/vbscript/global.c:
- if (FAILED(hres))
goto cleanup;
- hres = SafeArrayGetUBound(sa, 1, &ubound);
- if (FAILED(hres))
goto cleanup;
- hres = SafeArrayAccessData(sa, (void**)&data);
- if (FAILED(hres))
goto cleanup;
- delimiter_len = SysStringLen(delimiter);
- for (i = lbound; i <= ubound; i++) {
if (V_VT(&data[i]) != VT_BSTR) {
hres = to_string(&data[i], &str);
When `to_string` is called on an object, it internally invokes `Invoke(DISPID_VALUE)` on that object. This means that performing the conversion twice (once here and again in the later loop) can cause visible side effects in the script.
To avoid this, we could allocate an array of `BSTR`s, store the results of `to_string` in that array, and reuse them in the subsequent loop.