Skip to content

Commit 672a155

Browse files
committed
fix: prevent panic on possible C.GoString(nil) call
1 parent b850ca8 commit 672a155

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

pkg/emulator/machine.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,9 @@ func (m *Machine) CollectMCycleRootHashes(
397397
C.int32_t(log2BundleMcycleCount),
398398
previousPartialBundleC,
399399
&cResult))
400-
result = []byte(C.GoString(cResult))
400+
if err == nil {
401+
result = []byte(C.GoString(cResult))
402+
}
401403
})
402404
if err != nil {
403405
return nil, err
@@ -428,7 +430,9 @@ func (m *Machine) CollectUarchCycleRootHashes(
428430
C.int32_t(log2BundleUarchCycleCount),
429431
revertUarchTailC,
430432
&cResult))
431-
result = []byte(C.GoString(cResult))
433+
if err == nil {
434+
result = []byte(C.GoString(cResult))
435+
}
432436
})
433437

434438
if err != nil {

0 commit comments

Comments
 (0)