1 | /* |
1 | /* |
2 | parse_driver.c - Part of psiconv, a PSION 5 file formats converter |
2 | parse_driver.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
134 | psiconv_progress(config,lev+3,off,"Going to read clipart section %i",i); |
134 | psiconv_progress(config,lev+3,off,"Going to read clipart section %i",i); |
135 | if ((res = psiconv_parse_clipart_section(config,buf,lev+3,*entry,NULL,&clipart))) |
135 | if ((res = psiconv_parse_clipart_section(config,buf,lev+3,*entry,NULL,&clipart))) |
136 | goto ERROR4; |
136 | goto ERROR4; |
137 | if ((res = psiconv_list_add((*result)->sections,clipart))) |
137 | if ((res = psiconv_list_add((*result)->sections,clipart))) |
138 | goto ERROR5; |
138 | goto ERROR5; |
|
|
139 | free(clipart); |
139 | } |
140 | } |
140 | |
141 | |
141 | psiconv_free_jumptable_section(table); |
142 | psiconv_free_jumptable_section(table); |
142 | psiconv_progress(config,lev+1,off,"End of clipart file"); |
143 | psiconv_progress(config,lev+1,off,"End of clipart file"); |
143 | return res; |
144 | return res; |
144 | ERROR5: |
145 | ERROR5: |
145 | psiconv_free_clipart_section(clipart); |
146 | psiconv_free_clipart_section(clipart); |
146 | ERROR4: |
147 | ERROR4: |
147 | for (i = 0; i < psiconv_list_length((*result)->sections); i++) { |
148 | for (i = 0; i < psiconv_list_length((*result)->sections); i++) { |
148 | if (!(clipart = psiconv_list_get((*result)->sections,i))) { |
149 | if (!(clipart = psiconv_list_get((*result)->sections,i))) { |
149 | psiconv_error(config,lev+1,off,"Massive memory corruption"); |
150 | psiconv_error(config,lev+1,off,"Data structure corruption"); |
150 | goto ERROR3; |
151 | goto ERROR3; |
151 | } |
152 | } |
152 | psiconv_free_clipart_section(clipart); |
153 | psiconv_free_clipart_section(clipart); |
153 | } |
154 | } |
154 | psiconv_list_free((*result)->sections); |
155 | psiconv_list_free((*result)->sections); |
… | |
… | |
199 | if ((res = psiconv_parse_paint_data_section(config,buf,lev+3,*entry,NULL, |
200 | if ((res = psiconv_parse_paint_data_section(config,buf,lev+3,*entry,NULL, |
200 | 0,&paint))) |
201 | 0,&paint))) |
201 | goto ERROR4; |
202 | goto ERROR4; |
202 | if ((res = psiconv_list_add((*result)->sections,paint))) |
203 | if ((res = psiconv_list_add((*result)->sections,paint))) |
203 | goto ERROR5; |
204 | goto ERROR5; |
|
|
205 | free(paint); |
204 | } |
206 | } |
205 | |
207 | |
206 | psiconv_free_jumptable_section(table); |
208 | psiconv_free_jumptable_section(table); |
207 | psiconv_progress(config,lev+1,off,"End of mbm file"); |
209 | psiconv_progress(config,lev+1,off,"End of mbm file"); |
208 | return 0; |
210 | return 0; |
209 | ERROR5: |
211 | ERROR5: |
210 | psiconv_free_paint_data_section(paint); |
212 | psiconv_free_paint_data_section(paint); |
211 | ERROR4: |
213 | ERROR4: |
212 | for (i = 0; i < psiconv_list_length((*result)->sections); i++) { |
214 | for (i = 0; i < psiconv_list_length((*result)->sections); i++) { |
213 | if (!(paint = psiconv_list_get((*result)->sections,i))) { |
215 | if (!(paint = psiconv_list_get((*result)->sections,i))) { |
214 | psiconv_error(config,lev+1,off,"Massive memory corruption"); |
216 | psiconv_error(config,lev+1,off,"Data structure corruption"); |
215 | goto ERROR3; |
217 | goto ERROR3; |
216 | } |
218 | } |
217 | psiconv_free_paint_data_section(paint); |
219 | psiconv_free_paint_data_section(paint); |
218 | } |
220 | } |
219 | psiconv_list_free((*result)->sections); |
221 | psiconv_list_free((*result)->sections); |