Skip to content

Commit 07827c6

Browse files
jkleinscclaude
andcommitted
fix(patch): cast const away when freeing uv_cpu_info_t.model
libuv 1.52.1 typed uv_cpu_info_t.model as const char*, but uv__free takes void*. Electron builds with -Werror,-Wincompatible-pointer-types- discards-qualifiers, so add a cast. The memory is allocated via strdup so the cast is safe. Ref: nodejs/node#61829 Co-Authored-By: Claude <noreply@anthropic.com> (cherry picked from commit 90d1009)
1 parent 46b28d2 commit 07827c6

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎patches/node/.patches‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ fix_add_externalpointertypetag_to_v8_external_api_calls.patch
4747
fix_preserve_node_symbols_and_vtables_under_thinlto.patch
4848
electron_build-time_v8_code_cache_for_the_electron_js2c_bundles.patch
4949
electron_enable_node_startup_snapshot_generation_in_chromium_s_v8.patch
50+
chore_cast_const_away_when_freeing_uv_cpu_info_t_model.patch
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: John Kleinschmidt <jkleinsc@electronjs.org>
3+
Date: Mon, 1 Jun 2026 11:39:24 -0400
4+
Subject: chore: cast const away when freeing uv_cpu_info_t.model
5+
6+
libuv 1.52.x typed cpu_info_t.model as 'const char*' but uv_free_cpu_info()
7+
still passes it directly to uv__free() (void*). Electron builds with
8+
-Wincompatible-pointer-types-discards-qualifiers as an error, so cast
9+
explicitly to drop the const qualifier when freeing. The string was
10+
allocated with strdup() so the cast is safe.
11+
12+
This patch can be removed once libuv fixes the qualifier upstream.
13+
14+
diff --git a/deps/uv/src/uv-common.c b/deps/uv/src/uv-common.c
15+
index e5a7632909fc6592124b1b89d5ccfbe794ebd4a5..f1e8928d37ebf47225dbfd394fbf1163e1d9f666 100644
16+
--- a/deps/uv/src/uv-common.c
17+
+++ b/deps/uv/src/uv-common.c
18+
@@ -957,7 +957,7 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
19+
int i;
20+
21+
for (i = 0; i < count; i++)
22+
- uv__free(cpu_infos[i].model);
23+
+ uv__free((char*) cpu_infos[i].model);
24+
25+
uv__free(cpu_infos);
26+
#endif /* __linux__ */

0 commit comments

Comments
 (0)