Commit a87019e7 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

win_utf8_io.c : Fix potential memory leak.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
parent e0f638fa
......@@ -102,7 +102,7 @@ int get_utf8_argv(int *argc, char ***argv)
if ((wgetmainargs = (wgetmainargs_t)GetProcAddress(handle, "__wgetmainargs")) == NULL) return 1;
i = 0;
if (wgetmainargs(&wargc, &wargv, &wenv, 1, &i) != 0) return 1;
if ((utf8argv = (char **)malloc(wargc*sizeof(char*))) == NULL) return 1;
if ((utf8argv = (char **)calloc(wargc, sizeof(char*))) == NULL) return 1;
ret = 0;
for (i=0; i<wargc; i++) {
......@@ -120,6 +120,8 @@ int get_utf8_argv(int *argc, char ***argv)
*argc = wargc;
*argv = utf8argv;
} else {
for (i=0; i<wargc; i++)
free(utf8argv[i]);
free(utf8argv);
}
......
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