Use correct value for output_pairs.  Closes Coverity #1047326
Check return value of pairalloc.  Fixes Coverity #1135413