From e9c2dca046a6ba56d05e2ced882fe7338a2f6c3b Mon Sep 17 00:00:00 2001 From: Belousov Vladimir V Date: Fri, 3 Sep 2021 16:47:22 +0300 Subject: [PATCH 1/2] Fixed a crash of geany by the git-changebar plugin by changing a glong type to sptr_t in the SCI_ADDTEXT invoking (MinGW64 build) --- git-changebar/src/gcb-plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-changebar/src/gcb-plugin.c b/git-changebar/src/gcb-plugin.c index a911815f0..f8ce20cd6 100644 --- a/git-changebar/src/gcb-plugin.c +++ b/git-changebar/src/gcb-plugin.c @@ -801,7 +801,7 @@ get_widget_for_buf_range (GeanyDocument *doc, "UTF-8", doc->encoding, NULL); } - scintilla_send_message (sci, SCI_ADDTEXT, buf_len, (glong) buf); + scintilla_send_message (sci, SCI_ADDTEXT, buf_len, (sptr_t) buf); if (free_buf) { g_free (buf); @@ -1144,7 +1144,7 @@ insert_buf_range (GeanyDocument *doc, "UTF-8", doc->encoding, NULL); } - scintilla_send_message (old_sci, SCI_ADDTEXT, old_buf_len, (glong) old_buf); + scintilla_send_message (old_sci, SCI_ADDTEXT, old_buf_len, (sptr_t) old_buf); old_pos_start = sci_get_position_from_line (old_sci, old_start); old_pos_end = sci_get_position_from_line (old_sci, old_start + old_lines); From 8c1a01ed33b0e0d6651a276835f30cc9a2b54e5b Mon Sep 17 00:00:00 2001 From: Belousov Vladimir V Date: Mon, 6 Sep 2021 13:38:01 +0300 Subject: [PATCH 2/2] Fixed crashes in Lua, Macro and Numbered Bookmarks plugins under Win64 platform due to a different size of glong and sptr_t --- geanylua/glspi_sci.c | 2 +- geanymacro/src/geanymacro.c | 16 ++++++++-------- .../src/geanynumberedbookmarks.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/geanylua/glspi_sci.c b/geanylua/glspi_sci.c index f70c5ab2d..16913d9e3 100644 --- a/geanylua/glspi_sci.c +++ b/geanylua/glspi_sci.c @@ -452,7 +452,7 @@ static gint glspi_copy(lua_State* L) if (!lua_isstring(L,1)) {return FAIL_STRING_ARG(1);} content=lua_tostring(L,1); len=strlen(content); - if (len) { scintilla_send_message(doc->editor->sci,SCI_COPYTEXT,len,(glong)content); } + if (len) { scintilla_send_message(doc->editor->sci,SCI_COPYTEXT,len,(sptr_t)content); } push_number(L, len); return 1; default: diff --git a/geanymacro/src/geanymacro.c b/geanymacro/src/geanymacro.c index 2ac681301..b5b80764f 100644 --- a/geanymacro/src/geanymacro.c +++ b/geanymacro/src/geanymacro.c @@ -30,7 +30,7 @@ typedef struct { gint message; gulong wparam; - glong lparam; + sptr_t lparam; } MacroEvent; /* structure to hold details of a macro */ @@ -370,7 +370,7 @@ static void ReplayMacro(Macro *m) break; } - scintilla_send_message(sci,me->message,me->wparam,(glong)clipboardcontents); + scintilla_send_message(sci,me->message,me->wparam,(sptr_t)clipboardcontents); } else scintilla_send_message(sci,me->message,me->wparam,me->lparam); @@ -431,12 +431,12 @@ static MacroEvent * GetMacroEventFromString(gchar **s,gint *k) case SCI_SEARCHNEXT: case SCI_SEARCHPREV: /* get text */ - me->lparam=(glong)(g_strcompress(s[(*k)++])); + me->lparam=(sptr_t)(g_strcompress(s[(*k)++])); /* if text is empty string replace with NULL to signify use clipboard */ if((*((gchar*)(me->lparam)))==0) { g_free((gchar*)me->lparam); - me->lparam=(glong)NULL; + me->lparam=(sptr_t)NULL; } /* get search flags */ @@ -444,7 +444,7 @@ static MacroEvent * GetMacroEventFromString(gchar **s,gint *k) break; case SCI_REPLACESEL: /* get text */ - me->lparam=(glong)(g_strcompress(s[(*k)++])); + me->lparam=(sptr_t)(g_strcompress(s[(*k)++])); break; /* default handler for messages without extra data */ default: @@ -556,7 +556,7 @@ static gboolean Notification_Handler(GObject *obj,GeanyEditor *ed,SCNotification me->lparam=(me->message==SCI_SEARCHNEXT || me->message==SCI_SEARCHPREV || me->message==SCI_REPLACESEL) - ?((glong) g_strdup((gchar *)(nt->lParam))) : nt->lParam; + ?((sptr_t) g_strdup((gchar *)(nt->lParam))) : nt->lParam; /* more efficient to create reverse list and reverse it at the end */ RecordingMacro->MacroEvents=g_slist_prepend(RecordingMacro->MacroEvents,me); @@ -1971,7 +1971,7 @@ static void EditMacroElements(Macro *m) /* Special handling for text inserting, duplicate inserted string */ if(me->message==SCI_REPLACESEL) - me->lparam=(glong)((cTemp!=NULL)?g_strdup(cTemp):g_strdup("")); + me->lparam=(sptr_t)((cTemp!=NULL)?g_strdup(cTemp):g_strdup("")); /* Special handling for search */ if(me->message==SCI_SEARCHNEXT || me->message==SCI_SEARCHPREV) @@ -1979,7 +1979,7 @@ static void EditMacroElements(Macro *m) cTemp2=strchr(cTemp,','); cTemp2++; - me->lparam=(glong)(((*cTemp2)==0)?NULL:g_strdup(cTemp2)); + me->lparam=(sptr_t)(((*cTemp2)==0)?NULL:g_strdup(cTemp2)); me->wparam=strtoll(cTemp,NULL,10); } diff --git a/geanynumberedbookmarks/src/geanynumberedbookmarks.c b/geanynumberedbookmarks/src/geanynumberedbookmarks.c index 75a28d2e4..26f978df0 100644 --- a/geanynumberedbookmarks/src/geanynumberedbookmarks.c +++ b/geanynumberedbookmarks/src/geanynumberedbookmarks.c @@ -842,7 +842,7 @@ static gint NextFreeMarker(GeanyDocument* doc) break; /* insert new marker */ - scintilla_send_message(sci,SCI_MARKERDEFINEPIXMAP,m,(glong)(aszMarkerImages[k])); + scintilla_send_message(sci,SCI_MARKERDEFINEPIXMAP,m,(sptr_t)(aszMarkerImages[k])); scintilla_send_message(sci,SCI_MARKERADD,l,m); /* update markers record */ @@ -880,7 +880,7 @@ static void SetMarker(GeanyDocument* doc,gint bookmarkNumber,gint markerNumber,g /* insert new marker */ scintilla_send_message(sci,SCI_MARKERDEFINEPIXMAP,markerNumber, - (glong)(aszMarkerImages[bookmarkNumber])); + (sptr_t)(aszMarkerImages[bookmarkNumber])); scintilla_send_message(sci,SCI_MARKERADD,line,markerNumber); /* update record of which bookmark uses which marker */