This patch seems to fix the problem (sorry I failed to include it earlier.)
Index: pgrep.c =================================================================== --- pgrep.c (revision 7226) +++ pgrep.c (working copy) @@ -455,7 +455,7 @@ } else { list[++matches].num = task.XXXID; } - if (matches == size) { + if (matches == size -1) { size *= 2; list = realloc (list, size * sizeof (union el));