Skip to content

ExternalConn: Fix memory leak - #205

Merged
gonosztopi merged 1 commit into
amule-project:masterfrom
sc0w:PR_externalconn_leak
Aug 12, 2020
Merged

ExternalConn: Fix memory leak#205
gonosztopi merged 1 commit into
amule-project:masterfrom
sc0w:PR_externalconn_leak

Conversation

@sc0w

@sc0w sc0w commented Aug 6, 2020

Copy link
Copy Markdown
Member

No description provided.

@gonosztopi gonosztopi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though the patch does what is says, prevents a memory leak, there's a grave issue with this function: it allows adding several links at once and creates a response for each link, but only the last one is sent back to the client.

@gonosztopi
gonosztopi merged commit 004879a into amule-project:master Aug 12, 2020
@sc0w
sc0w deleted the PR_externalconn_leak branch August 12, 2020 20:27
ngosang pushed a commit to ngosang/amule that referenced this pull request Jun 20, 2026
i18n: fix non-ASCII mangling under default C locale (amule-project#203)
ngosang pushed a commit to ngosang/amule that referenced this pull request Jun 20, 2026
UPnPBase.cpp has four call sites that rely on tolower() producing
ASCII semantics:

  * stdStringIsEqualCI / stdStringStartsWithCI -- the two
    case-insensitive std::string helpers used throughout the file.
  * CUPnPService::Execute -- direct comparison against 'i' and 'n' to
    validate the UPnP argument direction string ("in" / "out").
  * CUPnPControlPoint::Callback BYEBYE case -- transforms the
    discovered device-type URN to lowercase before matching against
    UPnP::Device::IGW.

Under tr_TR.UTF-8 (and any other Turkish-locale variant), libc
tolower('I') returns U+0131 (dotless i) instead of 'i'. This
silently breaks UPnP direction validation, device-type matching,
namespace lowercase comparisons, and HTTP-header lowercasing --
amuled's UPnP auto-portforward stops working for Turkish-locale
users.

Before amule-project#205 (i18n: fix non-ASCII mangling under default C locale),
amuled stayed on the C locale throughout its lifetime and these
sites were silently safe. The fix in amule-project#205 made amuled pick LC_CTYPE
up from the environment so unicode2char() emits real UTF-8 -- which
exposed the latent Turkish-i issue documented above.

Wrap each tolower() scope in CCtypeAsciiScope -- the project's
existing RAII helper that pins LC_CTYPE = "C" for the duration of
its scope and restores it on destruction. Same pattern already used
in CamuleFileConfig.h (amule-project#852) and MaxMindDBDatabase.cpp.

amule (GUI) was already exposed to this bug via wxLocale's
setlocale(LC_ALL) on Turkish-language installs; the wrap fixes it
there too as a free side effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants