gozstd icon indicating copy to clipboard operation
gozstd copied to clipboard

missing error handling?

Open cfif1982 opened this issue 11 months ago • 0 comments

There is a file: https://github.com/valyala/gozstd/blob/master/writer.go#L163 line 163

inBuf := (*C.ZSTD_inBuffer)(C.calloc(1, C.sizeof_ZSTD_inBuffer))

if function calloc can't allocate memory and return nil - then there is a problem on next line.

inBuf.src = C.calloc(1, cstreamInBufSize) I mean: if inBuf == nil, then inBuf.src will cause panic

Should I make a check here? What should be done in this case?

cfif1982 avatar Mar 12 '25 12:03 cfif1982