summaryrefslogtreecommitdiffstats
path: root/src/svg/svg-color.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2014-10-11 17:15:03 +0000
committerJohan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl>2014-10-11 17:15:03 +0000
commita38add027810b9725f81cebb099282a8656e3aa3 (patch)
tree8812da03a3a0227bc0ec213868eca39dbc96593b /src/svg/svg-color.cpp
parentFix "Argument with 'nonnull' attribute passed null" API bug in extension colo... (diff)
downloadinkscape-a38add027810b9725f81cebb099282a8656e3aa3.tar.gz
inkscape-a38add027810b9725f81cebb099282a8656e3aa3.zip
Fix uninitialized variable use in svg-color.cpp. (additionally reduce scope of variable)
Bug found using clang static analyzer. The bug happens with color_out not being initialized upon definition; then 1. if(icc) == true 2. if(prof) == true 3. if(trans) == false 4. *r = color_out[0]; <-- un-init use Fixed by initializing color_out (with black). (bzr r13588)
Diffstat (limited to 'src/svg/svg-color.cpp')
-rw-r--r--src/svg/svg-color.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp
index 5108b7702..c9f22f8a4 100644
--- a/src/svg/svg-color.cpp
+++ b/src/svg/svg-color.cpp
@@ -511,18 +511,18 @@ sp_svg_create_color_hash()
void icc_color_to_sRGB(SVGICCColor* icc, guchar* r, guchar* g, guchar* b)
{
- guchar color_out[4];
- guchar color_in[4];
if (icc) {
g_message("profile name: %s", icc->colorProfile.c_str());
Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(icc->colorProfile.c_str());
if ( prof ) {
+ guchar color_out[4] = {0,0,0,0};
cmsHTRANSFORM trans = prof->getTransfToSRGB8();
if ( trans ) {
std::vector<colorspace::Component> comps = colorspace::getColorSpaceInfo( prof );
size_t count = CMSSystem::getChannelCount( prof );
size_t cap = std::min(count, comps.size());
+ guchar color_in[4];
for (size_t i = 0; i < cap; i++) {
color_in[i] = static_cast<guchar>((((gdouble)icc->colors[i]) * 256.0) * (gdouble)comps[i].scale);
g_message("input[%d]: %d", (int)i, (int)color_in[i]);