Skip to content

Commit 890a005

Browse files
committed
flush(): avoid memcpy(<dst>, NULL, 0)
During thread contention, it's possible for a thread to not call push() even once, leaving gs_thread[me] unallocated. The resulting call to memcpy() was noticed by a sanitizer during additional CRAN checks.
1 parent 5bbc4d5 commit 890a005

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/forder.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ static void flush(void) {
128128
if (!retgrp) return;
129129
int me = omp_get_thread_num();
130130
int n = gs_thread_n[me];
131+
if (!n) return;
131132
int newn = gs_n + n;
132133
if (gs_alloc < newn) {
133134
gs_alloc = (newn < nrow/3) ? (1+(newn*2)/4096)*4096 : nrow;

0 commit comments

Comments
 (0)