xolox / vim-shell

Improved integration between Vim and its environment (fullscreen, open URL, background command execution)
http://peterodding.com/code/vim/shell/
169 stars 13 forks source link

FIX: Don't return stack-allocated character buffer to Vim. #14

Closed inkarkat closed 11 years ago

inkarkat commented 11 years ago

This fixes #13 for me, but please review; it's been some time since I've seriously written C code, so I'm a bit rusty :-)

Thanks for looking so quickly into the issue I've submitted; I agree that your sprintf() change in aac1374 is correct, but that alone didn't change the symptoms of the problem at all. Fortunately, I have a minimal build environment, and I was able to get the DLL working by fiddling with the code, around what you've recently changed there.

The function-local rv string is allocated on the stack, that seems to work by pure chance in 32-bit, but fails in 64-bit. A simple fix is to make it a static string.

xolox commented 11 years ago

Thanks for taking a look at the code, especially given that you seem to have fixed the problem :-)! As you noticed my C is also a bit rusty; what you fixed was a beginners mistake :-(. I guess I've been spoiled by higher level languages for quite a while now...

I just merged your changes (some random unrelated changes sneaked in but they shouldn't change the compiled code) and I uploaded a new release which includes the new DLLs (0.12.9) to Vim Online and GitHub.