uart drivers: fix missing free(ndd.port)

This commit is contained in:
Philippe Teuwen 2013-03-17 22:54:15 +01:00
parent 77838b894c
commit c1372a009f
3 changed files with 4 additions and 5 deletions

View file

@ -549,11 +549,13 @@ acr122s_open(const nfc_context *context, const nfc_connstring connstring)
pnd = nfc_device_new(context, connstring); pnd = nfc_device_new(context, connstring);
if (!pnd) { if (!pnd) {
perror("malloc"); perror("malloc");
free(ndd.port);
acr122s_close(pnd); acr122s_close(pnd);
return NULL; return NULL;
} }
pnd->driver = &acr122s_driver; pnd->driver = &acr122s_driver;
strcpy(pnd->name, ACR122S_DRIVER_NAME); strcpy(pnd->name, ACR122S_DRIVER_NAME);
free(ndd.port);
pnd->driver_data = malloc(sizeof(struct acr122s_data)); pnd->driver_data = malloc(sizeof(struct acr122s_data));
if (!pnd->driver_data) { if (!pnd->driver_data) {

View file

@ -240,11 +240,11 @@ arygon_open(const nfc_context *context, const nfc_connstring connstring)
return NULL; return NULL;
} }
snprintf(pnd->name, sizeof(pnd->name), "%s:%s", ARYGON_DRIVER_NAME, ndd.port); snprintf(pnd->name, sizeof(pnd->name), "%s:%s", ARYGON_DRIVER_NAME, ndd.port);
free(ndd.port);
pnd->driver_data = malloc(sizeof(struct arygon_data)); pnd->driver_data = malloc(sizeof(struct arygon_data));
if (!pnd->driver_data) { if (!pnd->driver_data) {
perror("malloc"); perror("malloc");
free(ndd.port);
return NULL; return NULL;
} }
DRIVER_DATA(pnd)->port = sp; DRIVER_DATA(pnd)->port = sp;
@ -262,7 +262,6 @@ arygon_open(const nfc_context *context, const nfc_connstring connstring)
#ifndef WIN32 #ifndef WIN32
// pipe-based abort mecanism // pipe-based abort mecanism
if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) { if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) {
free(ndd.port);
return NULL; return NULL;
} }
#else #else

View file

@ -212,11 +212,11 @@ pn532_uart_open(const nfc_context *context, const nfc_connstring connstring)
return NULL; return NULL;
} }
snprintf(pnd->name, sizeof(pnd->name), "%s:%s", PN532_UART_DRIVER_NAME, ndd.port); snprintf(pnd->name, sizeof(pnd->name), "%s:%s", PN532_UART_DRIVER_NAME, ndd.port);
free(ndd.port);
pnd->driver_data = malloc(sizeof(struct pn532_uart_data)); pnd->driver_data = malloc(sizeof(struct pn532_uart_data));
if (!pnd->driver_data) { if (!pnd->driver_data) {
perror("malloc"); perror("malloc");
free(ndd.port);
return NULL; return NULL;
} }
DRIVER_DATA(pnd)->port = sp; DRIVER_DATA(pnd)->port = sp;
@ -235,7 +235,6 @@ pn532_uart_open(const nfc_context *context, const nfc_connstring connstring)
#ifndef WIN32 #ifndef WIN32
// pipe-based abort mecanism // pipe-based abort mecanism
if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) { if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) {
free(ndd.port);
return NULL; return NULL;
} }
#else #else
@ -246,7 +245,6 @@ pn532_uart_open(const nfc_context *context, const nfc_connstring connstring)
if (pn53x_check_communication(pnd) < 0) { if (pn53x_check_communication(pnd) < 0) {
nfc_perror(pnd, "pn53x_check_communication"); nfc_perror(pnd, "pn53x_check_communication");
pn532_uart_close(pnd); pn532_uart_close(pnd);
free(ndd.port);
return NULL; return NULL;
} }