#18299: wxTranslations::GetBestTranslation segmentation fault

10 views
Skip to first unread message

wxTrac

unread,
Dec 16, 2018, 9:05:27 PM12/16/18
to wx-...@googlegroups.com
#18299: wxTranslations::GetBestTranslation segmentation fault
----------------------------+--------------------
Reporter: slodki | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: base | Version: 3.1.2
Keywords: wxTranslations | Blocked By:
Blocking: | Patch: 0
----------------------------+--------------------
Calling
{{{
wxTranslations::Get()->GetBestTranslation("mydomain",
wxLANGUAGE_ENGLISH_US)
}}}
while mydomain translation's files are not available triggers assertion
{{{
../include/wx/arrstr.h(201): assert "nIndex < m_nCount" failed in Item():
wxArrayString: index out of bounds
}}}
then the fatal exception (segmentation fault).

I think the following implementation
{{{
wxString wxTranslations::GetBestTranslation(const wxString& domain,
const wxString& msgIdLanguage)
{
const wxArrayString allGoodOnes = GetAcceptableTranslations(domain,
msgIdLanguage);

wxLogTrace(TRACE_I18N, " => using language '%s'", allGoodOnes[0]);
return allGoodOnes[0];
}
}}}
should check if `allGoodOnes.IsEmpty()` before try to read the first
element.

Introduced in 5d08e404c76c1745e070d9c96055b90ffddd7177 commit

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18299>

wxTrac

unread,
Dec 17, 2018, 10:52:47 PM12/17/18
to wx-...@googlegroups.com
#18299: wxTranslations::GetBestTranslation segmentation fault
---------------------+-------------------------------------
Reporter: slodki | Owner: Vadim Zeitlin <vadim@…>
Type: defect | Status: closed
Priority: normal | Milestone:
Component: base | Version: 3.1.2
Resolution: fixed | Keywords: wxTranslations
Blocked By: | Blocking:
Patch: 0 |
---------------------+-------------------------------------
Changes (by Vadim Zeitlin <vadim@…>):

* owner: => Vadim Zeitlin <vadim@…>
* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"80904d1bc786ad2f6f8ab523391edfc82375820d/git-wxWidgets"
80904d1bc/git-wxWidgets]:
{{{
#!CommitTicketReference repository="git-wxWidgets"
revision="80904d1bc786ad2f6f8ab523391edfc82375820d"
Fix crash in translations code when no translations are found

Fix another regression in wxTranslations in 3.1.2 and check that the
vector of acceptable translations is not empty before using its first
element.

Closes https://github.com/wxWidgets/wxWidgets/pull/1082

Closes #18299.
}}}

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18299#comment:1>

wxTrac

unread,
Dec 23, 2018, 11:34:07 AM12/23/18
to wx-...@googlegroups.com
#18299: wxTranslations::GetBestTranslation segmentation fault
---------------------+-------------------------------------
Reporter: slodki | Owner: Vadim Zeitlin <vadim@…>
Type: defect | Status: closed
Priority: normal | Milestone:
Component: base | Version: 3.1.2
Resolution: fixed | Keywords: wxTranslations
Blocked By: | Blocking:
Patch: 0 |
---------------------+-------------------------------------

Comment (by Vadim Zeitlin <vadim@…>):

In [changeset:"270ad54abe7048d290031d6262a6d8c151e73375/git-wxWidgets"
270ad54ab/git-wxWidgets]:
{{{
#!CommitTicketReference repository="git-wxWidgets"
revision="270ad54abe7048d290031d6262a6d8c151e73375"
Revert all recent changes to wxTranslations

The latest changes to wxTranslations::AddCatalog() behaviour were not
backwards-compatible and also had other problem, so revert them for now,
even if this means that #18227 has to be reopened.

This is a combination of the following commits:

----

Revert "Fix regression in wxTranslations::AddCatalog()"

This reverts commit 14e905858d0c30b03914457f9fb5c49173366cd1.

See #18297.

----

Revert "Fix crash in translations code when no translations are found"

This reverts commit 80904d1bc786ad2f6f8ab523391edfc82375820d.

See #18299.

----

Revert "Rename new wxTranslations method to GetAcceptableTranslations()"

This reverts commit 20b02d6169fed3ae68caa6a12aa1003a205672f2.

----

Revert "Load catalogs for all preferred languages, if they exist"

This reverts commit 2d784da2ee12cc5a6d89b011827cff6361a12c23.

----

Revert "Allow getting all usable translations languages"

This reverts commit 5d08e404c76c1745e070d9c96055b90ffddd7177.

----

See #18227, #18300.

Closes #18302.
}}}

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18299#comment:2>
Reply all
Reply to author
Forward
0 new messages