app/test: fix crash after mbuf allocation failure

The patch fixes potential null pointer accesses in test_mbuf.
If 'm[i]' is null, stop accessing it.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
This commit is contained in:
Tetsuya Mukawa 2015-06-12 11:54:00 +09:00 committed by Thomas Monjalon
parent c91b871b8e
commit aa61307afc

View File

@ -594,6 +594,7 @@ test_pktmbuf_pool_ptr(void)
if (m[i] == NULL) {
printf("rte_pktmbuf_alloc() failed (%u)\n", i);
ret = -1;
break;
}
m[i]->data_off += 64;
}
@ -613,6 +614,7 @@ test_pktmbuf_pool_ptr(void)
if (m[i] == NULL) {
printf("rte_pktmbuf_alloc() failed (%u)\n", i);
ret = -1;
break;
}
if (m[i]->data_off != RTE_PKTMBUF_HEADROOM) {
printf("invalid data_off\n");