grep: don't rely on implementation-defined malloc(0) behavior
The very few places that rely on malloc/calloc of a zero-size region
won't attempt to dereference it, so just return NULL rather than rolling
the dice with the underlying malloc implementation.
Reported by: brooks, Shawn Webb
(cherry picked from commit e116e040f3091eca914a06dcd0bdd9f1aea23add)