Commit 388c3e9c authored by Michael Ensslin's avatar Michael Ensslin

Fixed some memory leaks in Utility/Embed.c

Found by clang's static analyzer.
None of those are significant, but we might as well fix them.
parent cc954ad9
...@@ -111,6 +111,7 @@ __Pyx_char2wchar(char* arg) ...@@ -111,6 +111,7 @@ __Pyx_char2wchar(char* arg)
unless there is a bug in the C library, or I unless there is a bug in the C library, or I
misunderstood how mbrtowc works. */ misunderstood how mbrtowc works. */
fprintf(stderr, "unexpected mbrtowc result -2\\n"); fprintf(stderr, "unexpected mbrtowc result -2\\n");
free(res);
return NULL; return NULL;
} }
if (converted == (size_t)-1) { if (converted == (size_t)-1) {
...@@ -169,15 +170,24 @@ int ...@@ -169,15 +170,24 @@ int
char *oldloc; char *oldloc;
if (!argv_copy || !argv_copy2) { if (!argv_copy || !argv_copy2) {
fprintf(stderr, "out of memory\\n"); fprintf(stderr, "out of memory\\n");
if (argv_copy)
free(argv_copy);
if (argv_copy2)
free(argv_copy2);
return 1; return 1;
} }
oldloc = strdup(setlocale(LC_ALL, NULL)); oldloc = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
argv_copy2[i] = argv_copy[i] = __Pyx_char2wchar(argv[i]); argv_copy2[i] = argv_copy[i] = __Pyx_char2wchar(argv[i]);
if (!argv_copy[i]) if (!argv_copy[i]) {
setlocale(LC_ALL, oldloc);
free(oldloc);
free(argv_copy);
free(argv_copy2);
return 1; return 1;
} }
}
setlocale(LC_ALL, oldloc); setlocale(LC_ALL, oldloc);
free(oldloc); free(oldloc);
res = __Pyx_main(argc, argv_copy); res = __Pyx_main(argc, argv_copy);
......
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