Realloc fix v1.0

Here's a fix for a bad realloc() pattern usage. It also contains a new test to avoid we reuse this pattern.

Ticket: https://redmine.openinfosecfoundation.org/issues/1062

PR builds:
- PR build: https://buildbot.suricata-ids.org/builders/regit/builds/75
- PR pcaps: https://buildbot.suricata-ids.org/builders/regit-pcap/builds/13