Skip to content

Commit 8587ba2

Browse files
tklausergopherbot
authored andcommitted
cmd/cgo: compare malloc return value to NULL instead of literal 0
Follow the pattern used in the other _cgoPREFIX_Cfunc* functions. This also avoids a -Wzero-as-null-pointer-constant warning when compiling with g++. Change-Id: I95ac8842df048105f4c738f3603136d9cfa2dfdc Reviewed-on: https://go-review.googlesource.com/c/go/+/664916 Auto-Submit: Keith Randall <[email protected]> Auto-Submit: Tobias Klauser <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: David Chase <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent cae4516 commit 8587ba2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/cgo/out.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ void _cgoPREFIX_Cfunc__Cmalloc(void *v) {
18121812
void *ret;
18131813
_cgo_tsan_acquire();
18141814
ret = malloc(a->p0);
1815-
if (ret == 0 && a->p0 == 0) {
1815+
if (ret == NULL && a->p0 == 0) {
18161816
ret = malloc(1);
18171817
}
18181818
a->r1 = ret;

0 commit comments

Comments
 (0)