strconv: fix compilation with `-cc gcc -cstrict -prod`

pull/10804/head
Delyan Angelov 2021-07-15 01:02:32 +03:00
parent de6918b8c9
commit 54dd510ace
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 6 additions and 1 deletions

View File

@ -68,7 +68,12 @@ pub fn (d Dec32) get_string_32(neg bool, i_n_digit int, i_pad_digit int) string
mut i := 0
if neg {
buf[i] = `-`
if buf.data != 0 {
// The buf.data != 0 check here, is needed for clean compilation
// with `-cc gcc -cstrict -prod`. Without it, gcc produces:
// error: potential null pointer dereference
buf[i] = `-`
}
i++
}