OpenToonz - An open-source full-featured 2D animation creation software
C
Update psdutils.CPP
JP Parks2fde67f3f08f
diff --git a/toonz/sources/common/psdlib/psd.cpp b/toonz/sources/common/psdlib/psd.cppindex 7703fe7ec..8149480b1 100644--- a/toonz/sources/common/psdlib/psd.cpp+++ b/toonz/sources/common/psdlib/psd.cpp@@ -220,8 +220,8 @@ bool TPSDReader::doLayersInfo() {m_headerInfo.layersCount = -m_headerInfo.layersCount;}if (!m_headerInfo.linfoBlockEmpty) {- m_headerInfo.linfo = (TPSDLayerInfo *)mymalloc(- m_headerInfo.layersCount * sizeof(struct TPSDLayerInfo));+ m_headerInfo.linfo = (TPSDLayerInfo *)mycalloc(+ m_headerInfo.layersCount, sizeof(struct TPSDLayerInfo));int i = 0;for (i = 0; i < m_headerInfo.layersCount; i++) {readLayerInfo(i);@@ -306,7 +306,9 @@ bool TPSDReader::readLayerInfo(int i) {}// process layer's 'additional info'-+ // Assumption: File will provide all layerIds or none at all.+ // Set layer id, for now, knowing it may be overwritten if found in file+ li->layerId = i + 1;li->additionalpos = ftell(m_file);li->additionallen = extrastart + extralen - li->additionalpos;doExtraData(li, li->additionallen);diff --git a/toonz/sources/common/psdlib/psdutils.cpp b/toonz/sources/common/psdlib/psdutils.cppindex 059bfc942..881be2fe1 100644--- a/toonz/sources/common/psdlib/psdutils.cpp+++ b/toonz/sources/common/psdlib/psdutils.cpp@@ -136,6 +136,15 @@ void *mymalloc(long n) {return NULL;}+void *mycalloc(long n, int size) {+ void *p = calloc(n, size);+ if (p)+ return p;+ else {+ // ALLOCATION ERROR+ }+ return NULL;+}// ZIP COMPRESSION// ZIP WITHOUT PREDICTIONdiff --git a/toonz/sources/common/psdlib/psdutils.h b/toonz/sources/common/psdlib/psdutils.hindex 714d4d817..1ac2960f4 100644--- a/toonz/sources/common/psdlib/psdutils.h+++ b/toonz/sources/common/psdlib/psdutils.h@@ -36,6 +36,7 @@ void readrow(FILE *psd, TPSDChannelInfo *chan, psdPixel rowIndex,void skipBlock(FILE *f);void *mymalloc(long n);+void *mycalloc(long n, int size);unsigned read2UBytes(FILE *f);int read2Bytes(FILE *f);long read4Bytes(FILE *f);