空指针 / 零指针:在编程中,指一个指针变量不指向任何有效的内存对象,通常保存为特殊值(如 NULL 或 nullptr)。对空指针进行解引用(访问其所指内容)常会导致程序崩溃或运行时错误。该术语也常出现在“空指针异常(null pointer exception)”等表达中。
/ˈnʌl ˌpɔɪntər/
The program crashed because it dereferenced a null pointer.
程序崩溃了,因为它对空指针进行了解引用。
To avoid security bugs, the function checks for a null pointer before copying data into the buffer.
为避免安全漏洞,该函数在把数据复制到缓冲区之前会先检查指针是否为空。
null 源自拉丁语 nullus,意为“没有、无”;pointer 来自 point(指向、指点)加上表示“做某事的人/物”的后缀 -er。合起来,“null pointer”字面意思是“指向‘无’的指针”,在计算机语境中引申为“不指向任何有效对象的指针”。
NULL 指针与指针使用规范。 NullPointerException 与对象引用为 null 的常见错误。 null 带来的复杂性与缺陷。