[PATCH wpan-tools 4/4] wpan-ping: make sure we do not leak conf during wrong options exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When we hit a wrong option and we are goignt o exit wpan-ping we might have
leaked conf. Not a real problem as we are goign to exit anyway at this point.
Still fix this. Thanks to the smatch tool for pointing this out.

Signed-off-by: Stefan Schmidt <stefan@xxxxxxxxxxxxxxx>
---
 wpan-ping/wpan-ping.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/wpan-ping/wpan-ping.c b/wpan-ping/wpan-ping.c
index edba8dd..92f4cf8 100644
--- a/wpan-ping/wpan-ping.c
+++ b/wpan-ping/wpan-ping.c
@@ -481,6 +481,7 @@ int main(int argc, char *argv[]) {
 			if (conf->packet_len >= MAX_PAYLOAD_LEN || conf->packet_len < MIN_PAYLOAD_LEN) {
 				printf("Packet size must be between %i and %i.\n",
 				       MIN_PAYLOAD_LEN, MAX_PAYLOAD_LEN - 1);
+				free(conf);
 				return 1;
 			}
 			break;
@@ -489,12 +490,15 @@ int main(int argc, char *argv[]) {
 			break;
 		case 'v':
 			fprintf(stdout, "wpan-ping " PACKAGE_VERSION "\n");
+			free(conf);
 			return 1;
 		case 'h':
 			usage(argv[0]);
+			free(conf);
 			return 1;
 		default:
 			usage(argv[0]);
+			free(conf);
 			return 1;
 		}
 	}
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux