From a38add027810b9725f81cebb099282a8656e3aa3 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 11 Oct 2014 19:15:03 +0200 Subject: 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) --- src/svg/svg-color.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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 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((((gdouble)icc->colors[i]) * 256.0) * (gdouble)comps[i].scale); g_message("input[%d]: %d", (int)i, (int)color_in[i]); -- cgit v1.2.3