diff --git a/src/hwcaps_freebsd_or_openbsd.c b/src/hwcaps_freebsd_or_openbsd.c index db90297c..775afe74 100644 --- a/src/hwcaps_freebsd_or_openbsd.c +++ b/src/hwcaps_freebsd_or_openbsd.c @@ -30,7 +30,10 @@ const char* CpuFeatures_GetBasePlatformPointer(void); #include static unsigned long GetElfHwcapFromElfAuxInfo(int hwcap_type) { - unsigned long hwcap; + unsigned long hwcap = 0; + // elf_aux_info() leaves the output buffer untouched when the requested entry + // is absent (e.g. AT_HWCAP2 on some arch/kernel combos), so initializing + // hwcap to 0 avoids returning an indeterminate value on failure. elf_aux_info(hwcap_type, &hwcap, sizeof(hwcap)); return hwcap; }