use-after-scope 指“在对象/变量的作用域结束后仍继续使用它”的程序错误(常见于 C/C++)。典型情形是:函数返回后仍使用指向局部变量(栈上对象)的指针/引用,导致未定义行为,可能引发崩溃或安全漏洞。
/ˌjuːs ˌæftər ˈskoʊp/
This crash was caused by a use-after-scope bug.
这次崩溃是由“作用域结束后仍使用”的错误引起的。
Because the pointer still referenced a local variable after the function returned, the program triggered a use-after-scope and produced unpredictable results.
由于该指针在函数返回后仍指向一个局部变量,程序触发了 use-after-scope,产生了不可预测的结果。
该词由编程术语组合而来:use-after-(“在……之后仍使用”)+ scope(“作用域”)。它仿照更常见的漏洞命名方式 use-after-free(释放后使用),强调问题发生在“离开作用域(生命周期结束)”之后。