Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

越界问题 #32

Open
nevata opened this issue Mar 3, 2025 · 0 comments
Open

越界问题 #32

nevata opened this issue Mar 3, 2025 · 0 comments

Comments

@nevata
Copy link

nevata commented Mar 3, 2025

func (m MemoryDeviceType) String() string {
types := [...]string{
"Other",
"Unknown",
"DRAM",
"EDRAM",
"VRAM",
"SRAM",
"RAM",
"ROM",
"FLASH",
"EEPROM",
"FEPROM",
"EPROM",
"CDRAM",
"3DRAM",
"SDRAM",
"SGRAM",
"RDRAM",
"DDR",
"DDR2",
"DDR2 FB-DIMM",
"Reserved1",
"Reserved2",
"Reserved3",
"DDR3",
"FBD2",
"DDR4",
"LPDDR",
"LPDDR2",
"LPDDR3",
"LPDDR4",
"Logical non-volatile device",
"HBM",
"HBM2",
"DDR5",
"LPDDR5",
"HBM3",
}

    // 防止越界
if int(m-1) > len(types) {
	return types[0]
}

return types[m-1] //没有以上代码,新硬件,这里直接崩溃,有很多类似这种代码,望修正

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant