Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: third_party/lcms2-2.6/src/cmsxform.c

Issue 2359243003: Fix memory leaks in lcms (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/lcms2-2.6/src/cmstypes.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //------------------------------------------------------------------------------ --- 1 //------------------------------------------------------------------------------ ---
2 // 2 //
3 // Little Color Management System 3 // Little Color Management System
4 // Copyright (c) 1998-2014 Marti Maria Saguer 4 // Copyright (c) 1998-2014 Marti Maria Saguer
5 // 5 //
6 // Permission is hereby granted, free of charge, to any person obtaining 6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the "Software"), 7 // a copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation 8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 // for separated transforms. If this is the case, 586 // for separated transforms. If this is the case,
587 static 587 static
588 _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut, 588 _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
589 cmsUInt32Number Intent, cmsUInt32 Number* InputFormat, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags) 589 cmsUInt32Number Intent, cmsUInt32 Number* InputFormat, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags)
590 { 590 {
591 _cmsTransformPluginChunkType* ctx = ( _cmsTransformPluginChunkType*) _cmsCo ntextGetClientChunk(ContextID, TransformPlugin); 591 _cmsTransformPluginChunkType* ctx = ( _cmsTransformPluginChunkType*) _cmsCo ntextGetClientChunk(ContextID, TransformPlugin);
592 _cmsTransformCollection* Plugin; 592 _cmsTransformCollection* Plugin;
593 593
594 // Allocate needed memory 594 // Allocate needed memory
595 _cmsTRANSFORM* p = (_cmsTRANSFORM*) _cmsMallocZero(ContextID, sizeof(_cmsTRA NSFORM)); 595 _cmsTRANSFORM* p = (_cmsTRANSFORM*) _cmsMallocZero(ContextID, sizeof(_cmsTRA NSFORM));
596 if (!p) return NULL; 596 if (!p) {
597 cmsPipelineFree(lut);
598 return NULL;
599 }
597 600
598 // Store the proposed pipeline 601 // Store the proposed pipeline
599 p ->Lut = lut; 602 p ->Lut = lut;
600 603
601 // Let's see if any plug-in want to do the transform by itself 604 // Let's see if any plug-in want to do the transform by itself
602 for (Plugin = ctx ->TransformCollection; 605 for (Plugin = ctx ->TransformCollection;
603 Plugin != NULL; 606 Plugin != NULL;
604 Plugin = Plugin ->Next) { 607 Plugin = Plugin ->Next) {
605 608
606 if (Plugin ->Factory(&p->xform, &p->UserData, &p ->FreeUserData, &p ->Lut, InputFormat, OutputFormat, dwFlags)) { 609 if (Plugin ->Factory(&p->xform, &p->UserData, &p ->FreeUserData, &p ->Lut, InputFormat, OutputFormat, dwFlags)) {
(...skipping 29 matching lines...) Expand all
636 if (_cmsFormatterIsFloat(*InputFormat) && _cmsFormatterIsFloat(*OutputFormat )) { 639 if (_cmsFormatterIsFloat(*InputFormat) && _cmsFormatterIsFloat(*OutputFormat )) {
637 640
638 // Get formatter function always return a valid union, but the contents of this union may be NULL. 641 // Get formatter function always return a valid union, but the contents of this union may be NULL.
639 p ->FromInputFloat = _cmsGetFormatter(ContextID, *InputFormat, cmsForma tterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat; 642 p ->FromInputFloat = _cmsGetFormatter(ContextID, *InputFormat, cmsForma tterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
640 p ->ToOutputFloat = _cmsGetFormatter(ContextID, *OutputFormat, cmsForma tterOutput, CMS_PACK_FLAGS_FLOAT).FmtFloat; 643 p ->ToOutputFloat = _cmsGetFormatter(ContextID, *OutputFormat, cmsForma tterOutput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
641 *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER; 644 *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER;
642 645
643 if (p ->FromInputFloat == NULL || p ->ToOutputFloat == NULL) { 646 if (p ->FromInputFloat == NULL || p ->ToOutputFloat == NULL) {
644 647
645 cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported r aster format"); 648 cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported r aster format");
646 _cmsFree(ContextID, p); 649 cmsDeleteTransform(p);
647 return NULL; 650 return NULL;
648 } 651 }
649 652
650 if (*dwFlags & cmsFLAGS_NULLTRANSFORM) { 653 if (*dwFlags & cmsFLAGS_NULLTRANSFORM) {
651 654
652 p ->xform = NullFloatXFORM; 655 p ->xform = NullFloatXFORM;
653 } 656 }
654 else { 657 else {
655 // Float transforms don't use cach? always are non-NULL 658 // Float transforms don't use cach? always are non-NULL
656 p ->xform = FloatXFORM; 659 p ->xform = FloatXFORM;
657 } 660 }
658 661
659 } 662 }
660 else { 663 else {
661 664
662 if (*InputFormat == 0 && *OutputFormat == 0) { 665 if (*InputFormat == 0 && *OutputFormat == 0) {
663 p ->FromInput = p ->ToOutput = NULL; 666 p ->FromInput = p ->ToOutput = NULL;
664 *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER; 667 *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER;
665 } 668 }
666 else { 669 else {
667 670
668 int BytesPerPixelInput; 671 int BytesPerPixelInput;
669 672
670 p ->FromInput = _cmsGetFormatter(ContextID, *InputFormat, cmsFormat terInput, CMS_PACK_FLAGS_16BITS).Fmt16; 673 p ->FromInput = _cmsGetFormatter(ContextID, *InputFormat, cmsFormat terInput, CMS_PACK_FLAGS_16BITS).Fmt16;
671 p ->ToOutput = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormat terOutput, CMS_PACK_FLAGS_16BITS).Fmt16; 674 p ->ToOutput = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormat terOutput, CMS_PACK_FLAGS_16BITS).Fmt16;
672 675
673 if (p ->FromInput == NULL || p ->ToOutput == NULL) { 676 if (p ->FromInput == NULL || p ->ToOutput == NULL) {
674 677
675 cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupport ed raster format"); 678 cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupport ed raster format");
676 _cmsFree(ContextID, p); 679 cmsDeleteTransform(p);
677 return NULL; 680 return NULL;
678 } 681 }
679 682
680 BytesPerPixelInput = T_BYTES(p ->InputFormat); 683 BytesPerPixelInput = T_BYTES(p ->InputFormat);
681 if (BytesPerPixelInput == 0 || BytesPerPixelInput >= 2) 684 if (BytesPerPixelInput == 0 || BytesPerPixelInput >= 2)
682 *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER; 685 *dwFlags |= cmsFLAGS_CAN_CHANGE_FORMATTER;
683 686
684 } 687 }
685 688
686 if (*dwFlags & cmsFLAGS_NULLTRANSFORM) { 689 if (*dwFlags & cmsFLAGS_NULLTRANSFORM) {
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 cmsSignalError(xform -> ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsuppor ted raster format"); 1126 cmsSignalError(xform -> ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsuppor ted raster format");
1124 return FALSE; 1127 return FALSE;
1125 } 1128 }
1126 1129
1127 xform ->InputFormat = InputFormat; 1130 xform ->InputFormat = InputFormat;
1128 xform ->OutputFormat = OutputFormat; 1131 xform ->OutputFormat = OutputFormat;
1129 xform ->FromInput = FromInput; 1132 xform ->FromInput = FromInput;
1130 xform ->ToOutput = ToOutput; 1133 xform ->ToOutput = ToOutput;
1131 return TRUE; 1134 return TRUE;
1132 } 1135 }
OLDNEW
« no previous file with comments | « third_party/lcms2-2.6/src/cmstypes.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698