Skip to content

Commit

Permalink
apply util_malloc() (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-tk committed Aug 1, 2021
1 parent 66cecb8 commit d315123
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/util/utiliof.c
Original file line number Diff line number Diff line change
Expand Up @@ -2992,7 +2992,7 @@ get_wstring_from_mbstring(int cp, const char *mbstr, wchar_t *wstr)
return NULL;
}
if (wstr==NULL) {
wstr = malloc(sizeof(wchar_t)*(len+1));
wstr = util_malloc(sizeof(wchar_t)*(len+1));
}
len = MultiByteToWideChar(cp, 0, mbstr, -1, wstr, len+1);
if (len==0) {
Expand All @@ -3010,7 +3010,7 @@ FILE *ppu8open(const char *filename, const char *mode)
unsigned char *p;
size_t len = strlen(filename);

fnn = malloc(len + 10);
fnn = util_malloc(len + 10);
p = strstr(filename, ".\\");
if (!p) {
p = strstr(filename, "./");
Expand Down Expand Up @@ -3050,8 +3050,10 @@ FILE *ppu8open(const char *filename, const char *mode)
if (wfilename == NULL)
return NULL;
wmode = get_wstring_from_mbstring(cp, mode, wmode=NULL);
if (wmode == NULL)
if (wmode == NULL) {
free(wfilename);
return NULL;
}
ret = _wfopen((const wchar_t *)wfilename, (const wchar_t *)wmode);
free(wfilename);
free(wmode);
Expand Down

0 comments on commit d315123

Please sign in to comment.