- rc = getchar_func(ctx, curpacket->packet->length,
- curpacket->packet->data);
+ if (curpacket->packet->data == NULL) {
+ logthing(LOGTHING_ERROR,
+ "Can't allocate memory for "
+ "packet!");
+ rc = -1;
+ } else {
+ rc = getchar_func(ctx,
+ curpacket->packet->length,
+ curpacket->packet->data);
+ }
+ }