Skip to contentSkip to conversation

maketable: clean up resources

PATCH In review gaoxingwang 2 participants 3 messages Oct 12, 2022 – Oct 20, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 maketable: clean up resources

---
 netem/maketable.c | 3 +++
 1 file changed, 3 insertions(+)
netem/maketable.c +3 -0
index ccb8f0c6..f91ce221 100644
@@ -230,5 +230,8 @@ main(int argc, char **argv)
 	inverse = inverttable(table, TABLESIZE, DISTTABLESIZE, total);
 	interpolatetable(inverse, TABLESIZE);
 	printtable(inverse, TABLESIZE);
+	free(table);
+	free(inverse)
+	close(fp);
 	return 0;
 }
Signature · 1 line
2.27.0
#1 lore raw
Quoted 10 lines · On Wed, 12 Oct 2022 17:35:34 +0800 gaoxingwang <[email protected]> wrote:
---
 netem/maketable.c | 3 +++
 1 file changed, 3 insertions(+)
netem/maketable.c +0 -0
index ccb8f0c6..f91ce221 100644

netem/maketable.c main(int argc, char **argv) · line 237

Quoted 8 lines
netem/maketable.c +3 -0
@@ -230,5 +230,8 @@ main(int argc, char **argv)
 	inverse = inverttable(table, TABLESIZE, DISTTABLESIZE, total);
 	interpolatetable(inverse, TABLESIZE);
 	printtable(inverse, TABLESIZE);
+	free(table);
+	free(inverse)
+	close(fp);
 	return 0;
 }

Why bother. This is a tool only used during builds and this the end of the main program so all resources will disappear after return.

#2 lore raw

On Mon, 17 Oct 2022 20:29:14 -0700 [thread overview]

Quoted 8 lines
Quoted 5 lines · On Wed, 12 Oct 2022 17:35:34 +0800 gaoxingwang <[email protected]> wrote:
---
 netem/maketable.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 16 lines

netem/maketable.c main(int argc, char **argv) · line 237

Quoted 13 lines
netem/maketable.c +3 -0
index ccb8f0c6..f91ce221 100644
@@ -230,5 +230,8 @@ main(int argc, char **argv)
 	inverse = inverttable(table, TABLESIZE, DISTTABLESIZE, total);
 	interpolatetable(inverse, TABLESIZE);
 	printtable(inverse, TABLESIZE);
+	free(table);
+	free(inverse)
+	close(fp);
 	return 0;
 }

Why bother. This is a tool only used during builds and this the end of the main program so all resources will disappear after return.

I found this issue because a white box scan of the code. Maybe fixing this will save us from the effort to explain it.