Commit 66932417 authored by Nikias Bassen's avatar Nikias Bassen

plistutil: Use static buffer for stat()

parent 801a72a3
...@@ -112,13 +112,12 @@ int main(int argc, char *argv[]) ...@@ -112,13 +112,12 @@ int main(int argc, char *argv[])
uint32_t size = 0; uint32_t size = 0;
int read_size = 0; int read_size = 0;
char *plist_entire = NULL; char *plist_entire = NULL;
struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); struct stat filestats;
options_t *options = parse_arguments(argc, argv); options_t *options = parse_arguments(argc, argv);
if (!options) if (!options)
{ {
print_usage(argc, argv); print_usage(argc, argv);
free(filestats);
return 0; return 0;
} }
...@@ -127,9 +126,9 @@ int main(int argc, char *argv[]) ...@@ -127,9 +126,9 @@ int main(int argc, char *argv[])
if (!iplist) if (!iplist)
return 1; return 1;
stat(options->in_file, filestats); stat(options->in_file, &filestats);
plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1)); plist_entire = (char *) malloc(sizeof(char) * (filestats.st_size + 1));
read_size = fread(plist_entire, sizeof(char), filestats->st_size, iplist); read_size = fread(plist_entire, sizeof(char), filestats.st_size, iplist);
fclose(iplist); fclose(iplist);
// convert from binary to xml or vice-versa // convert from binary to xml or vice-versa
...@@ -145,7 +144,6 @@ int main(int argc, char *argv[]) ...@@ -145,7 +144,6 @@ int main(int argc, char *argv[])
} }
plist_free(root_node); plist_free(root_node);
free(plist_entire); free(plist_entire);
free(filestats);
if (plist_out) if (plist_out)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment