search: Avoid segfault when given an invalid base

This patch avoids an easily reproduced segmentation violation when
base_path is NULL (as a consequence of being an invalid/non-existent)
path.

Signed-off-by: Anton Lofgren <anton.lofgren@gmail.com>