Fix symbol list
authorRobert Pengelly <robertapengelly@hotmail.com>
Thu, 12 Jun 2025 20:12:53 +0000 (21:12 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Thu, 12 Jun 2025 20:12:53 +0000 (21:12 +0100)
ranlib.c

index c513f05d7d5d8c4a8ea2d7fcf0b35412e0e505b2..728a962fc4472b702d81074cc0ad9f5d32fbc9c6 100644 (file)
--- a/ranlib.c
+++ b/ranlib.c
@@ -408,7 +408,7 @@ static void hunk_get_symbols (void *object, unsigned long bytes, long offset) {
             
             while (1) {
             
-                name_size = array_to_be_integer (pos, 4);
+                name_size = array_to_integer (pos, 4);
                 pos += 4;
                 
                 if (name_size == 0) {
@@ -427,24 +427,26 @@ static void hunk_get_symbols (void *object, unsigned long bytes, long offset) {
                     pos += 4;
                 } else if (symbol_type == 129 || symbol_type == 130 || symbol_type == 136) {
                 
+                    strtab = xmalloc (sizeof (*strtab));
+                    strtab->length = strlen (symname);
+                    
+                    strtab->name = xstrdup (symname);
+                    strtab->offset = offset;
+                    
+                    add_strtab (&gstrtab, strtab);
+                    
                     if (symbol_type == 130) {
                         pos += 4;
                     }
                     
-                    num_ref = array_to_be_integer (pos, 4);
+                    num_ref = array_to_integer (pos, 4);
                     num_ref *= 4;
                     
                     pos = pos + 4 + num_ref;
                 
                 }
                 
-                strtab = xmalloc (sizeof (*strtab));
-                strtab->length = strlen (symname);
-                
-                strtab->name = symname;
-                strtab->offset = offset;
-                
-                add_strtab (&gstrtab, strtab);
+                free (symname);
             
             }