memory safety

This commit is contained in:
2025-09-06 12:54:34 +02:00
parent 97bcd5eda7
commit 75c9ce171d
3 changed files with 10 additions and 0 deletions

BIN
a.out

Binary file not shown.

BIN
helpelf

Binary file not shown.

10
main.c
View File

@@ -146,6 +146,9 @@ void check_dynamic32(Elf32_Ehdr* header, FILE* fp)
{ {
printf("statically linked, "); printf("statically linked, ");
} }
free(p_headers);
free((char*)interpstr);
} }
void display_elf32(Elf32_Ehdr* header, FILE* fp) void display_elf32(Elf32_Ehdr* header, FILE* fp)
@@ -332,6 +335,9 @@ void check_sec32(Elf32_Ehdr* header, FILE* fp)
canary = true; canary = true;
} }
} }
free(syms);
free(strtab);
} }
} }
@@ -394,8 +400,12 @@ void check_sec32(Elf32_Ehdr* header, FILE* fp)
break; break;
} }
} }
free(dyns);
} }
free(s_headers);
free(s_header_strtab);
free(p_headers);
} }
void display_elf64(Elf64_Ehdr* header) void display_elf64(Elf64_Ehdr* header)