diff options
| author | Marcel Holtmann <marcel@holtmann.org> | 2005-09-07 17:23:00 +0000 | 
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2005-09-07 17:23:00 +0000 | 
| commit | a8b5fad54044c7b5e7c6aa30ad24e5a86fc51daf (patch) | |
| tree | 129bfe1b3b4ebf5232087ea12ed315872434c062 | |
| parent | 9848c1fa4ee7b49d425cb790fe9ab5edff8761dd (diff) | |
Fix memory leaks with textfile_get() usage
| -rw-r--r-- | common/test_textfile.c | 3 | ||||
| -rw-r--r-- | hcid/storage.c | 7 | 
2 files changed, 10 insertions, 0 deletions
| diff --git a/common/test_textfile.c b/common/test_textfile.c index 54202d2c..5a783d20 100644 --- a/common/test_textfile.c +++ b/common/test_textfile.c @@ -34,6 +34,7 @@  #include <errno.h>  #include <fcntl.h>  #include <unistd.h> +#include <stdlib.h>  #include <string.h>  #include "textfile.h" @@ -64,6 +65,8 @@ int main(int argc, char *argv[])  		str = textfile_get(filename, key);  		if (!str)  			fprintf(stderr, "No value for %s\n", key); +		else +			free(str);  	}  	return 0; diff --git a/hcid/storage.c b/hcid/storage.c index e270cbd8..e8d2ce1c 100644 --- a/hcid/storage.c +++ b/hcid/storage.c @@ -37,6 +37,7 @@  #include <ctype.h>  #include <fcntl.h>  #include <unistd.h> +#include <stdlib.h>  #include <malloc.h>  #include <sys/file.h>  #include <sys/stat.h> @@ -87,6 +88,8 @@ int read_device_name(bdaddr_t *local, bdaddr_t *peer, char *name)  		str[248] = '\0';  	strcpy(name, str); +	free(str); +  	return 0;  } @@ -162,6 +165,8 @@ int read_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key)  		key[i] = (uint8_t) strtol(tmp, NULL, 16);  	} +	free(str); +  	return 0;  } @@ -181,5 +186,7 @@ int read_pin_code(bdaddr_t *local, bdaddr_t *peer, char *pin)  	strncpy(pin, str, 16);  	len = strlen(pin); +	free(str); +  	return len;  } | 
