Handle asprintf() allocation failures in pingpong examples.
Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
int sockfd = -1;
struct pingpong_dest *rem_dest = NULL;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return NULL;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
int sockfd = -1, connfd;
struct pingpong_dest *rem_dest = NULL;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return NULL;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
int sockfd = -1;
struct pingpong_dest *rem_dest = NULL;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return NULL;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
int sockfd = -1, connfd;
struct pingpong_dest *rem_dest = NULL;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return NULL;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
int sockfd = -1;
struct pingpong_dest *rem_dest = NULL;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return NULL;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
int sockfd = -1, connfd;
struct pingpong_dest *rem_dest = NULL;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return NULL;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
int sockfd = -1;
struct pingpong_dest *rem_dest = NULL;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return NULL;
+
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
int sockfd = -1, connfd;
struct pingpong_dest *rem_dest = NULL;
- asprintf(&service, "%d", port);
+ if (asprintf(&service, "%d", port) < 0)
+ return NULL;
+
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {