Commit 3f906bc957957b40f4fe6836510f770d65d0fe38

Authored by Imanol-Mikel Barba Sabariego
1 parent 5d5390ce

Fixed leaks (Closes #2)

Showing 1 changed file with 8 additions and 6 deletions
... ... @@ -96,13 +96,13 @@ void destroyTag(Tag* t) {
96 96 free(t->name);
97 97 }
98 98  
99   - if(t->type == TAG_BYTEARRAY || t->type == TAG_INTARRAY || t->type == TAG_LIST) {
100   - destroyTagList((TagList*)t->payload);
101   - } else if(t->type == TAG_COMPOUND) {
102   - destroyTagCompound((TagCompound*)t->payload);
103   - }
104   -
105 99 if(t->payloadLength) {
  100 +
  101 + if(t->type == TAG_BYTEARRAY || t->type == TAG_INTARRAY || t->type == TAG_LIST) {
  102 + destroyTagList((TagList*)t->payload);
  103 + } else if(t->type == TAG_COMPOUND) {
  104 + destroyTagCompound((TagCompound*)t->payload);
  105 + }
106 106 free(t->payload);
107 107 }
108 108 }
... ... @@ -111,12 +111,14 @@ void destroyTagList(TagList* l) {
111 111 for(int i = 0; i < l->size; ++i) {
112 112 destroyTag(&l->list[i]);
113 113 }
  114 + free(l->list);
114 115 }
115 116  
116 117 void destroyTagCompound(TagCompound* tc) {
117 118 for(int i = 0; i < tc->numTags; ++i) {
118 119 destroyTag(&tc->list[i]);
119 120 }
  121 + free(tc->list);
120 122 }
121 123  
122 124 size_t getTypeSize(uint8_t type) {
... ...