Backporting SciTE and the Crash in ScintillaCall.cxx

"'[email protected]' via scite-interest" <[email protected]> Fri, 9 May 2025 06:23:35 -0700 (PDT)
Newsgroups gmane.editors.scite.general
Message-ID <[email protected]>
------=_Part_51110_1411072561.1746797015842
Content-Type: multipart/alternative; 
	boundary="----=_Part_51111_1313042829.1746797015842"

------=_Part_51111_1313042829.1746797015842
Content-Type: text/plain; charset="UTF-8"

Hi Neal, 
we had some night spare time on our extended Lan and one of us does 
backporting for a livin. He backported SciTe within a night, which is 
impressiv, but we had a problem.
std::string ScintillaCall::CallReturnString(Message msg, uintptr_t wParam) {
    // Get the length of the data from CallPointer
    size_t len = CallPointer(msg, wParam, nullptr);
    
    // Ensure len is valid and non-zero
    if (len == 0) {
        return std::string();  // Return empty string if length is 0
    }
    
    std::string result(len, '\0');  // Initialize the string with 'len' 
null characters
    CallPointer(msg, wParam, &result[0]);
    return result;
}

 We used BackportCpp which dod great with one exception. its not 100% 
compliant. we couldnt use result.data() so he came up with the above 
solution. First, without the len guard it crashed. (debugging showed that 
len was sometimes zero) . With the above implementation it seems to be 
fine. so id like to share here in case there are other people wnting to use 
BackportCpp.  Ill share the diffs too when they ready. Have a nice Day!
Thorsten 

-- 
You received this message because you are subscribed to the Google Groups "scite-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/scite-interest/ed4eecb2-d1af-4d85-bf42-846b29bbff9dn%40googlegroups.com.

------=_Part_51111_1313042829.1746797015842
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Neal,=C2=A0<br />we had some night spare time on our extended Lan and on=
e of us does backporting for a livin. He backported SciTe within a night, w=
hich is impressiv, but we had a problem.<div style=3D"color: rgb(0, 0, 0); =
font-family: Consolas, &quot;Courier New&quot;, monospace; line-height: 19p=
x; white-space: pre;"><div><span style=3D"color: rgb(38, 127, 153);">
std</span>::<span style=3D"color: rgb(38, 127, 153);">string</span> <span s=
tyle=3D"color: rgb(38, 127, 153);">ScintillaCall</span>::<span style=3D"col=
or: rgb(121, 94, 38);">CallReturnString</span>(<span style=3D"color: rgb(38=
, 127, 153);">Message</span> <span style=3D"color: rgb(0, 16, 128);">msg</s=
pan>, <span style=3D"color: rgb(38, 127, 153);">uintptr_t</span> <span styl=
e=3D"color: rgb(0, 16, 128);">wParam</span>) {</div><div><span style=3D"col=
or: rgb(0, 128, 0);">=C2=A0 =C2=A0 // Get the length of the data from CallP=
ointer</span></div><div>=C2=A0 =C2=A0 <span style=3D"color: rgb(38, 127, 15=
3);">size_t</span> <span style=3D"color: rgb(0, 16, 128);">len</span> =3D <=
span style=3D"color: rgb(121, 94, 38);">CallPointer</span>(<span style=3D"c=
olor: rgb(0, 16, 128);">msg</span>, <span style=3D"color: rgb(0, 16, 128);"=
>wParam</span>, <span style=3D"color: rgb(0, 0, 255);">nullptr</span>);</di=
v><div>=C2=A0 =C2=A0 </div><div><span style=3D"color: rgb(0, 128, 0);">=C2=
=A0 =C2=A0 // Ensure len is valid and non-zero</span></div><div>=C2=A0 =C2=
=A0 <span style=3D"color: rgb(175, 0, 219);">if</span> (<span style=3D"colo=
r: rgb(0, 16, 128);">len</span> =3D=3D <span style=3D"color: rgb(9, 134, 88=
);">0</span>) {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 <span style=3D"color:=
 rgb(175, 0, 219);">return</span> <span style=3D"color: rgb(38, 127, 153);"=
>std</span>::<span style=3D"color: rgb(38, 127, 153);">string</span>();<spa=
n style=3D"color: rgb(0, 128, 0);"> =C2=A0// Return empty string if length =
is 0</span></div><div>=C2=A0 =C2=A0 }</div><div>=C2=A0 =C2=A0 </div><div>=
=C2=A0 =C2=A0 <span style=3D"color: rgb(38, 127, 153);">std</span>::<span s=
tyle=3D"color: rgb(38, 127, 153);">string</span> <span style=3D"color: rgb(=
0, 16, 128);">result</span>(<span style=3D"color: rgb(0, 16, 128);">len</sp=
an>, <span style=3D"color: rgb(163, 21, 21);">'</span><span style=3D"color:=
 rgb(238, 0, 0);">\0</span><span style=3D"color: rgb(163, 21, 21);">'</span=
>);<span style=3D"color: rgb(0, 128, 0);"> =C2=A0// Initialize the string w=
ith 'len' null characters</span></div><div>=C2=A0 =C2=A0 <span style=3D"col=
or: rgb(121, 94, 38);">CallPointer</span>(<span style=3D"color: rgb(0, 16, =
128);">msg</span>, <span style=3D"color: rgb(0, 16, 128);">wParam</span>, &=
amp;<span style=3D"color: rgb(0, 16, 128);">result</span><span style=3D"col=
or: rgb(121, 94, 38);">[</span><span style=3D"color: rgb(9, 134, 88);">0</s=
pan><span style=3D"color: rgb(121, 94, 38);">]</span>);</div><div>=C2=A0 =
=C2=A0 <span style=3D"color: rgb(175, 0, 219);">return</span> <span style=
=3D"color: rgb(0, 16, 128);">result</span>;</div><div>}</div><br /></div><d=
iv>=C2=A0We used BackportCpp which dod great with one exception. its not 10=
0% compliant. we couldnt use result.data() so he came up with the above sol=
ution. First, without the len guard it crashed. (debugging showed that len =
was sometimes zero) . With the above implementation it seems to be fine. so=
 id like to share here in case there are other people wnting to use Backpor=
tCpp.=C2=A0 Ill share the diffs too when they ready. Have a nice Day!<br />=
Thorsten=C2=A0</div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;scite-interest&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">scit=
[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
scite-interest/ed4eecb2-d1af-4d85-bf42-846b29bbff9dn%40googlegroups.com?utm=
_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/scit=
e-interest/ed4eecb2-d1af-4d85-bf42-846b29bbff9dn%40googlegroups.com</a>.<br=
 />

------=_Part_51111_1313042829.1746797015842--

------=_Part_51110_1411072561.1746797015842--