Adding a single line of code fontname = "Consolas";
to assign a string, causes an execution crash in 64-bit compiled code, but is fine for 32-bit.
For 32-bit compilation, I installed MingW-w64 as i686/Threads-W32/Exceptions-Dwarf and for 64-bit I chose x86_64/Exceptions-seh and tried both win32 and posix.
The code is from PuTTY Open Source Terminal Emulator, unchanged other than my above line. Note that the line before my amendment fontname = read_setting_s(handle, name);
successfully sets fontname and all I'm doing is overriding it by setting it again to a new string. Any ideas?
Filename: winstore.c
FontSpec *read_setting_fontspec(settings_r *handle, const char *name) { char *settingname; char *fontname; FontSpec *ret; int isbold, height, charset; fontname = read_setting_s(handle, name); /* New line below */ fontname = "Consolas"; if (!fontname) return NULL; settingname = dupcat(name, "IsBold"); isbold = read_setting_i(handle, settingname, -1); sfree(settingname); if (isbold == -1) { sfree(fontname); return NULL; } settingname = dupcat(name, "CharSet"); charset = read_setting_i(handle, settingname, -1); sfree(settingname); if (charset == -1) { sfree(fontname); return NULL; } settingname = dupcat(name, "Height"); height = read_setting_i(handle, settingname, INT_MIN); sfree(settingname); if (height == INT_MIN) { sfree(fontname); return NULL; } ret = fontspec_new(fontname, isbold, height, charset); sfree(fontname); return ret; }
Additional.
ummm luck? You're assigning a const char* to a char*? who knows what is being done with the filename pointer in all the subroutine calls...I don't remember if C has warnings about losing the const modifier...
Last edit: Doug Semler 2021-07-11
Many thanks, I can see what's happening now.
This is resolved now, it was caused by
free(fontname);
after assigning the constant.Last edit: Oso B 2021-07-11