From 1300cec38cc48405715416f107a65a4d7d608767 Mon Sep 17 00:00:00 2001
From: grischka <grischka>
Date: Sun, 11 May 2008 00:11:52 +0200
Subject: [PATCH] free_section bugfix

---
 tcc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tcc.c b/tcc.c
index b402a9bd..7acb7bf0 100644
--- a/tcc.c
+++ b/tcc.c
@@ -1284,9 +1284,9 @@ Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags)
 
 static void free_section(Section *s)
 {
-    if (s->link && 0 == s->link->sh_num)
+    if (s->link && (s->link->sh_flags & SHF_PRIVATE))
         free_section(s->link);
-    if (s->hash && 0 == s->hash->sh_num)
+    if (s->hash && (s->link->sh_flags & SHF_PRIVATE))
         s->hash->link = NULL, free_section(s->hash);
     tcc_free(s->data);
     tcc_free(s);