As pointed by Coverity, in the "Configuration" panel of WPrefs there are
some images loaded, but if the images cannot be loaded correctly then the
returned NULL pointer can crash the application as it is dereferenced in
further function calls.
To solve this case, this patch is adding a NULL pointer check in the
functions RScaleImage (wrlib) and WMCreatePixmapFromRImage (WINGs), so both
can accept that NULL pointer to also return NULL, which means the existing
check for "icon == NULL" in the WPrefs code will be useful.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
For code maintainability, it is better to have a single definition of the
constant than many ones dispatched in many places. In addition, we try to
count on the constant M_PI that can be defined by the header <math.h> if
possible because it may have the best accuracy for the platform.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
When defining enums as types instead of simple enums allows to use these
types at the places where the corresponding enum values are expected, then
allowing the compiler to check that, potentially reporting incorrect use
of values to the user.
This patch adds types for the configuration fields in the RContextAttributes
structure.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Using local function prototype redefinition is dangerous, now a single
prototype is seen in all the files that are concerned.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The equality comparison (a == b) is known to be a dangerous trap
when floating-point arithmetics are involved. This patch changes
all the cases which try to do this to a safer check.
As found by Rodolfo, it looks like there could be memory leak in the
function 'RSmoothScaleImage' because it reserveda given number of
memory blocs but used another count to free them after use.
This patch uses the same count for release as it seems this variable
is not modified in between. Took the opportunity as Rodolfo proposed
to convert a global variable to a local variable - this global
definition seems incorrect.
Non-obvious fixes:
WINGs/wfilepanel.c: Cast to void to avoid an unused calculated value
warning.
WINGs/wtabview.c: Test tab<0 to avoid a warning from the next condition
about signed overflow in an inlined invocation of the function.
Signed-off-by: Brad Jorsch <anomie@users.sourceforge.net>
I've found a buffer overflow problem in RSmoothScaleImage. There are
some scaling calculations involving floats which are finally converted
to integers. Since such conversion does not round the number, just
truncates the decimal part, sometimes the number is smaller than it
should be. As a result, smaller buffer is allocated for picture
scaling and thus buffer overflow occurs.
Strange thing is that this bug has not appeared earlier so it probably
has something to do with newer gcc or glibc (I switch from
"prehistoric" Fedora Core 5 to Fedora 12).
<What about the symptoms?>
There were several ones, probably depending on application version and
compilation flags. First, it just stopped responding. Looking at the
process with strace I saw it locked in some FUTEX wait (unfortunately
I don't have the logs). Second, it just crashed. And last I got
complaint from glibc about double free or corrupted heap before
malloc. I've found the bug through wmweather+ dockapp, versions 2.9
and 2.11 (http://sourceforge.net/projects/wmweatherplus/), I've never
encountered it in WindowMaker itself.
for arq in `git ls-files *.c`; do
echo $arq;
indent -linux -l115 $arq;
done
The different line break at 115 columns is because
I use a widescreen monitor :-)
- Separated the font caches for normal fonts and fontsets in WINGs (they can
have the same names and collide in the cache giving unwanted results)
- Updated the years in the copyright notices
---------------
- Added retain/release mechanism to RImage by adding RRetainImage() and
RReleaseImage(). RDestroyImage() is an alias to RReleaseImage() now, but
will be removed in a future release because it no longer fits with the
semantics. Will be kept for a while to allow a smoother transition.
More about in wrlib/NEWS
For WINGs:
----------
- Small API change:
1. Renamed WMSetApplicationIconImage(), WMGetApplicationIconImage() and
WMSetWindowMiniwindowImage() to respectively WMSetApplicationIconPixmap(),
WMGetApplicationIconPixmap() and WMSetWindowMiniwindowPixmap()
They operate on a WMPixmap which is practically an X Pixmap with no alpha
channel information and the new name is more suggestive and also leaves
room for the new functions added for operating on images with alpha info.
2. Added WMSetApplicationIconImage() and WMGetApplicationIconImage() which
operate on an RImage and store alpha information too.
3. Added WMGetApplicationIconBlendedPixmap() which will take the image with
alpha set by WMSetApplicationIconImage() and will blend it with a color.
If color is NULL it will blend using the default panel color (#aeaaae)
All these changes will allow WINGs to handle images with alpha blending
correctly in panels and wherever else needed. More about in WINGs/NEWS.
- updated panels to use the newly available RImages if present and fallback
to old WMPixmaps if not, to properly show alpha blended images.
- replaced some still left malloc's with wmalloc's.
For Window Maker:
-----------------
- Fixed wrong mapping position of the "Docked Applications Panel" for some
icons.
- Smoother animation for the smiley =)
- Made images with alpha blending be shown correctly in the panels and the
icon chooser.
- The icon image set to be shown in panels ("Logo.WMPanel") will be
automatically updated if its entry in WMWindowAttributes changes (without
a need to restart as until now).
*** Note!!! ***
If you are developing applications with one of libwraster or libWINGs
then you should look to wrlib/NEWS and WINGs/NEWS to see what changed
and how should you update your code.