struct stat st;
if (stat(python_pkgdir, &st)) {
qd_error_errno(errno, "Cannot find Python library path '%s'", python_pkgdir);
return NULL;
} else if (!S_ISDIR(st.st_mode)) { // dispatch.c, line 99
qd_error(QD_ERROR_RUNTIME, "Python library path '%s' not a directory", python_pkgdir);
return NULL;
}
==2028==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x56b3c3 in qd_dispatch /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/dispatch.c:99:20
#1 0x4c2346 in main_process /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/router/src/main.c:92:16
#2 0x4c05d8 in main /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/router/src/main.c:369:9
#3 0x7f398fd39b74 in __libc_start_main (/lib64/libc.so.6+0x27b74)
#4 0x43fdbd in _start (/__w/qpid-dispatch/qpid-dispatch/qpid-dispatch/build/router/qdrouterd+0x43fdbd)
Uninitialized value was created by an allocation of 'st' in the stack frame of function 'qd_dispatch'
#0 0x56ab90 in qd_dispatch /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/dispatch.c:77
SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/dispatch.c:99:20 in qd_dispatch
我的代码中可能出了什么问题?据我所知,我只st.st_mode
在调用stat
成功时触摸。我要归咎于我的编译器、消毒剂或 glibc 中的错误。
我唯一能想到的就是拆开包装if
。执行 a if ( ... != 0) return
,删除else
不需要的 (由于return
之前的原因),以使代码更常规。不过,这不会改变意思。