git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
examples/vhost: fix path allocation failure handling
[dpdk.git]
/
examples
/
vhost
/
main.c
diff --git
a/examples/vhost/main.c
b/examples/vhost/main.c
index
645cf51
..
5e914f5
100644
(file)
--- a/
examples/vhost/main.c
+++ b/
examples/vhost/main.c
@@
-353,11
+353,19
@@
port_init(uint16_t port)
static int
us_vhost_parse_socket_path(const char *q_arg)
{
static int
us_vhost_parse_socket_path(const char *q_arg)
{
+ char *old;
+
/* parse number string */
if (strnlen(q_arg, PATH_MAX) == PATH_MAX)
return -1;
/* parse number string */
if (strnlen(q_arg, PATH_MAX) == PATH_MAX)
return -1;
+ old = socket_files;
socket_files = realloc(socket_files, PATH_MAX * (nb_sockets + 1));
socket_files = realloc(socket_files, PATH_MAX * (nb_sockets + 1));
+ if (socket_files == NULL) {
+ free(old);
+ return -1;
+ }
+
snprintf(socket_files + nb_sockets * PATH_MAX, PATH_MAX, "%s", q_arg);
nb_sockets++;
snprintf(socket_files + nb_sockets * PATH_MAX, PATH_MAX, "%s", q_arg);
nb_sockets++;