Skip to content

Commit d2482ae

Browse files
zhaozgsantigimeno
authored andcommitted
macos: fix memleaks in uv__get_cpu_speed
ERROR: LeakSanitizer: detected memory leaks ``` Direct leak of 432 byte(s) in 9 object(s) allocated from: #0 0x1062eedc2 in __sanitizer_mz_calloc+0x92 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x46dc2) #1 0x7fff20171eb6 in _malloc_zone_calloc+0x3a (libsystem_malloc.dylib:x86_64+0x1beb6) #2 0x7fff203ac180 in _CFRuntimeCreateInstance+0x124 (CoreFoundation:x86_64h+0x4180) #3 0x7fff203ab906 in __CFStringCreateImmutableFunnel3+0x84d (CoreFoundation:x86_64h+0x3906) #4 0x7fff203ab0a1 in CFStringCreateWithCString+0x48 (CoreFoundation:x86_64h+0x30a1) #5 0x1056f63e1 in uv__get_cpu_speed darwin.c:267 #6 0x1056f491e in uv_cpu_info darwin.c:338 ``` PR-URL: libuv#3098 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
1 parent 580d1d9 commit d2482ae

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/unix/darwin.c

+5
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ static int uv__get_cpu_speed(uint64_t* speed) {
305305

306306
err = 0;
307307
out:
308+
if (device_type_str != NULL)
309+
pCFRelease(device_type_str);
310+
if (clock_frequency_str != NULL)
311+
pCFRelease(clock_frequency_str);
312+
308313
if (core_foundation_handle != NULL)
309314
dlclose(core_foundation_handle);
310315

0 commit comments

Comments
 (0)