Skip to content

Fix curl handle/header leaks and per-event socket leak on Linux - #54

Merged
Gogoshika-ga merged 1 commit into
mainfrom
fix/curl-and-socket-leaks
Aug 31, 2026
Merged

Gogoshika-ga merged 1 commit into
mainfrom
fix/curl-and-socket-leaks

Conversation

@Gogoshika-ga

Copy link
Copy Markdown
Member

Fixes the two leaks reported in GameAnalytics/GA-SDK-UNITY#59.

Curl client (all desktop platforms)

  • curl_easy_cleanup was skipped when curl_easy_perform failed — each failed request leaked the easy handle (on Windows this pins two loopback TCP sockets per failure, eventually exhausting sockets machine-wide with WSAENOBUFS).
  • The header curl_slist was never freed — leaked on every request.

Both are now owned by RAII guards (std::unique_ptr with curl deleters), so every exit path cleans up. Also removed a duplicate CURLOPT_SSL_VERIFYPEER setopt.

Linux getConnectionType()

The inner int sock = socket(...) shadowed the outer sock, so close() never ran — leaking one socket per network interface per event. Now a single socket is opened per call, reused for every interface ioctl, closed once; the loop breaks early once WIFI is detected. Semantics unchanged.

@Gogoshika-ga
Gogoshika-ga requested a review from dorin-ga August 31, 2026 09:10
@Gogoshika-ga Gogoshika-ga self-assigned this Aug 31, 2026
@Gogoshika-ga Gogoshika-ga added the bug Something isn't working label Aug 31, 2026
@github-actions

Copy link
Copy Markdown

LCOV of commit 2596bf3 during Test Coverage #153

Summary coverage rate:
  lines......: 40.6% (1155 of 2843 lines)
  functions..: 52.5% (210 of 400 functions)
  branches...: no data found

Files changed coverage rate: n/a

@Gogoshika-ga
Gogoshika-ga merged commit 76e5880 into main Aug 31, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sendRequest leaks the curl handle on the error path; GALinux getConnectionType leaks a socket per interface

2 participants