Skip to content

Commit

Permalink
fixed a heavy bug on malloc structure
Browse files Browse the repository at this point in the history
  • Loading branch information
White Dragon committed Jul 15, 2018
1 parent fd702cb commit 5feeccd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions engine/psp/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ static int findPaks(void)
if(filelist == NULL) filelist = malloc(sizeof(fileliststruct));
else
{
copy = malloc(i * sizeof(fileliststruct));
memcpy(copy, filelist, i * sizeof(fileliststruct));
copy = malloc((i + 1) * sizeof(fileliststruct));
memcpy(copy, filelist, (i + 1) * sizeof(fileliststruct));
free(filelist);
filelist = malloc((i + 1) * sizeof(fileliststruct));
memcpy(filelist, copy, i * sizeof(fileliststruct));
memcpy(filelist, copy, (i + 1) * sizeof(fileliststruct));
free(copy); copy = NULL;
}
memset(&filelist[i], 0, sizeof(fileliststruct));
Expand Down
6 changes: 3 additions & 3 deletions engine/sdl/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ static int findPaks(void)
if(filelist == NULL) filelist = malloc(sizeof(fileliststruct));
else
{
copy = malloc(i * sizeof(fileliststruct));
memcpy(copy, filelist, i * sizeof(fileliststruct));
copy = malloc((i + 1) * sizeof(fileliststruct));
memcpy(copy, filelist, (i + 1) * sizeof(fileliststruct));
free(filelist);
filelist = malloc((i + 1) * sizeof(fileliststruct));
memcpy(filelist, copy, i * sizeof(fileliststruct));
memcpy(filelist, copy, (i + 1) * sizeof(fileliststruct));
free(copy); copy = NULL;
}
memset(&filelist[i], 0, sizeof(fileliststruct));
Expand Down
6 changes: 3 additions & 3 deletions engine/vita/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ static int findPaks(void)
if (filelist == NULL) filelist = malloc(sizeof(fileliststruct));
else
{
copy = malloc(i * sizeof(fileliststruct));
memcpy(copy, filelist, i * sizeof(fileliststruct));
copy = malloc((i + 1) * sizeof(fileliststruct));
memcpy(copy, filelist, (i + 1) * sizeof(fileliststruct));
free(filelist);
filelist = malloc((i + 1) * sizeof(fileliststruct));
memcpy(filelist, copy, i * sizeof(fileliststruct));
memcpy(filelist, copy, (i + 1) * sizeof(fileliststruct));
free(copy); copy = NULL;
}
memset(&filelist[i], 0, sizeof(fileliststruct));
Expand Down
6 changes: 3 additions & 3 deletions engine/wii/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,11 @@ static int findPaks(void)
if(filelist == NULL) filelist = malloc(sizeof(fileliststruct));
else
{
copy = malloc(i * sizeof(fileliststruct));
memcpy(copy, filelist, i * sizeof(fileliststruct));
copy = malloc((i + 1) * sizeof(fileliststruct));
memcpy(copy, filelist, (i + 1) * sizeof(fileliststruct));
free(filelist);
filelist = malloc((i + 1) * sizeof(fileliststruct));
memcpy(filelist, copy, i * sizeof(fileliststruct));
memcpy(filelist, copy, (i + 1) * sizeof(fileliststruct));
free(copy); copy = NULL;
}
memset(&filelist[i], 0, sizeof(fileliststruct));
Expand Down

4 comments on commit 5feeccd

@msmalik681
Copy link
Collaborator

@msmalik681 msmalik681 commented on 5feeccd Aug 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DCurrent
This broke the pak selection menu for PC and Android not sure about PSP but WII was still working.

White Dragon described this as a heavy bug I wanted to revert the changes but was there a bug the way it was before ?

@DCurrent
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was never aware of any bug. He never described the problem. Revert in a private build and test. We'll go from there.

@msmalik681
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DCurrent

Works when reverted.

@DCurrent
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go ahead and make a pull request then, and I'll merge it with master.

Please sign in to comment.