Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak #36

Open
wants to merge 2 commits into
base: features/cictec-fixes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/det_vesa.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ void detectar_vesa(void) { // Detects available video modes
} else {
for(i=0;modes[i];++i) {
modos[i].ancho=modes[i]->w; modos[i].alto=modes[i]->h; modos[i].modo=1;
free(modes[i]);
}
num_modos=i-1;
free(modes);

}

Expand Down
12 changes: 5 additions & 7 deletions src/shared/osdep/osd_sdl12.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void OSDEP_SetCaption(char *title, char *icon) {
OSDEP_VMode **OSDEP_ListModes(void) {
SDL_Rect **modes;
int i;
static OSDEP_VMode *smodes[1024];
OSDEP_VMode **smodes;

modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
if(modes == (SDL_Rect **)0) {
Expand All @@ -71,15 +71,13 @@ OSDEP_VMode **OSDEP_ListModes(void) {
return -1;
}

for(i = 0; modes[i]; ++i) {
if(modes[i]) {
smodes = calloc(1024, sizeof(OSDEP_VMode *));

for(i = 0; i < 1023 && modes[i]; ++i) {
//Note: smodes[1023] reserved to NULL
smodes[i] = (OSDEP_VMode *)malloc(sizeof(OSDEP_VMode));
smodes[i]->w = modes[i]->w;
smodes[i]->h = modes[i]->h;
}
else {
smodes[i] = NULL;
}
}

return smodes;
Expand Down