alice-ar: fix bug when extracting linked webp

Need to pass the archive as an argument so that base CGs can be
retrieved.
This commit is contained in:
Nunuhara Cabbage
2020-07-30 20:41:24 -07:00
parent 86568bc610
commit a8b2e91053
3 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -23,9 +23,10 @@
struct cg;
struct cg_metrics;
struct archive;
bool webp_checkfmt(const uint8_t *data);
void webp_extract(uint8_t *data, size_t size, struct cg *cg);
void webp_extract(uint8_t *data, size_t size, struct cg *cg, struct archive *ar);
void webp_get_metrics(uint8_t *data, size_t size, struct cg_metrics *m);
#endif /* SYSTEM4_WEBP_H */
+1 -1
View File
@@ -106,7 +106,7 @@ struct cg *cg_load_data(struct archive_data *dfile)
WARNING("Unimplemented CG type: PNG");
break;
case ALCG_WEBP:
webp_extract(dfile->data, dfile->size, cg);
webp_extract(dfile->data, dfile->size, cg, dfile->archive);
break;
case ALCG_DCF:
dcf_extract(dfile->data, dfile->size, cg);
+2 -2
View File
@@ -64,7 +64,7 @@ static int get_base_cg(uint8_t *data, size_t size)
return LittleEndian_getDW(data, size-4);
}
void webp_extract(uint8_t *data, size_t size, struct cg *cg)
void webp_extract(uint8_t *data, size_t size, struct cg *cg, struct archive *ar)
{
cg->pixels = WebPDecodeRGBA(data, size, &cg->metrics.w, &cg->metrics.h);
webp_init_metrics(&cg->metrics);
@@ -75,7 +75,7 @@ void webp_extract(uint8_t *data, size_t size, struct cg *cg)
return;
// FIXME: possible infinite recursion on broken/malicious ALD
struct cg *base_cg = cg_load(ald[ALDFILE_CG], base-1);
struct cg *base_cg = cg_load(ar, base-1);
if (base_cg->metrics.w != cg->metrics.w || base_cg->metrics.h != cg->metrics.h) {
ERROR("webp base CG dimensions don't match: (%d,%d) / (%d,%d)",
base_cg->metrics.w, base_cg->metrics.h, cg->metrics.w, cg->metrics.h);