JSandusky / ImGuiCLI

C++/CLI wrapper for DearImGui Viewports branch
MIT License
6 stars 3 forks source link

Crash with InputText with null string #3

Closed KakCAT closed 6 years ago

KakCAT commented 6 years ago

Hi,

using (in example) ImGuiCli.InputText ("Name",ref objName); , being objName null crashes trying to copy the string. I suppose it would be better to throw an exception when this happens, otherwise a very scary error message about memory protection appears :)

(being c# and the string passed as a ref, I suppose the best way to react would be to maintain the string as null, until a key is typed, then creating a brand new string, but I'm not up to date of the internals of the lib, so I don't know if this is possible)

KakCAT commented 6 years ago

Another issue with InputText. Strings do weird things. In example, I have 2 objects with a name. In example, 'near' and 'far'

When I switch between those objects the name changes ok with near, but instead of far prints farr. I think the final (\0) is not being copied in CopyStrBuff

-> memcpy(target, linkStr, strlen(linkStr)+1);

JSandusky commented 6 years ago

Both of these are fixed now.

JSandusky commented 6 years ago

Closing now, haven't noticed anything else with strings.

JSandusky commented 6 years ago

Just hit me, you probably have unmanaged code debugging turned off in your project - that's probably why the exception was of the uselessly terrifying variety. Not worth turning it on unless you're fiddling in the guts of the wrapper.

I'm mulling over exception raising, leaning towards keeping the API tolerant of garbage in (it's GUI, you're going to see garbage if you put it in).

KakCAT commented 6 years ago

sorry for the delay, I took a break.

Yes, it's possible that the problem came from the unmanaged code debugging, as I switched it on in order to find the error. I probably didn't switch it off again.