DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2637
Version: 1.3.0


The attached patch fixes two errors reported by Valgrind. These are on a 64
bit Linux system.

First error probably only comes up in certain dual monitor configurations.
Observed on a system using the proprietary Nvidia driver.

Second error may be 64 bit specific?



==7833== Invalid read of size 4
==7833==    at 0x510047: screen_init() (screen_xywh.cxx:155)
==7833==    by 0x510249: Fl::screen_xywh(int&, int&, int&, int&, int, int)
(screen_xywh.cxx:197)
==7833==    by 0x4F8FFE: Fl_X::make_xid(Fl_Window*, XVisualInfo*, unsigned
long) (Fl_x.cxx:1594)
==7833==    by 0x4FA1D2: Fl_Window::show() (Fl_x.cxx:1876)
==7833==    by 0x4C6A97: Fl_Double_Window::show()
(Fl_Double_Window.cxx:68)
==7833==    by 0x4D9E4F: Fl_Overlay_Window::show()
(Fl_Overlay_Window.cxx:46)
==7833==    by 0x4F3C8C: Fl_Window::show(int, char**) (Fl_arg.cxx:361)
==7833==    by 0x47BC74: Fl_Utilities::showWindow(Fl_Window*, int, char**,
char const* const*) (Fl_Utilities.cxx:142)
==7833==    by 0x412945: DsViewerApp::run(int, char**)
(DsViewerApp.cxx:72)
==7833==    by 0x4113FB: main (DSviewer.cxx:52)
==7833==  Address 0x7a9bf60 is not stack'd, malloc'd or (recently) free'd
==7833== 
==7833== Invalid read of size 1
==7833==    at 0x501FAD: xrgb_converter(unsigned char const*, unsigned
char*, int, int) (fl_draw_image.cxx:323)
==7833==    by 0x502A9F: innards(unsigned char const*, int, int, int, int,
int, int, int, void (*)(void*, int, int, int, unsigned char*), v
==7833==    by 0x502D14: Fl_Xlib_Graphics_Driver::draw_image(unsigned char
const*, int, int, int, int, int, int) (fl_draw_image.cxx:547)
==7833==    by 0x4C7117: fl_draw_image(unsigned char const*, int, int,
int, int, int, int) (fl_draw.H:667)
==7833==    by 0x4CACA9: alpha_blend(Fl_RGB_Image*, int, int, int, int,
int, int) (Fl_Image.cxx:431)
==7833==    by 0x4CB2BE: Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image*, int,
int, int, int, int, int) (Fl_Image.cxx:573)
==7833==    by 0x4CAD2A: Fl_RGB_Image::draw(int, int, int, int, int, int)
(Fl_Image.cxx:438)
==7833==    by 0x4BDE35: Fl_Image::draw(int, int) (Fl_Image.H:160)
==7833==    by 0x5004D8: fl_draw(char const*, int, int, int, int, unsigned
int, void (*)(char const*, int, int, int), Fl_Image*, int) (fl_d
==7833==    by 0x500D0C: fl_draw(char const*, int, int, int, int, unsigned
int, Fl_Image*, int) (fl_draw.cxx:386)
==7833==    by 0x5065F0: fl_normal_label(Fl_Label const*, int, int, int,
int, unsigned int) (fl_labeltype.cxx:46)
==7833==    by 0x50674C: Fl_Label::draw(int, int, int, int, unsigned int)
const (fl_labeltype.cxx:88)
==7833==  Address 0x7d2bbc0 is 0 bytes after a block of size 720 alloc'd
==7833==    at 0x4C283AD: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7833==    by 0x52600C: operator new(unsigned long) (in
/home/cbiegl/EDAS-sw/ds-devel-3.0/bin/Debug/Linux/x86_64/DSviewer)
==7833==    by 0x5251A8: operator new[](unsigned long) (in
/home/cbiegl/EDAS-sw/ds-devel-3.0/bin/Debug/Linux/x86_64/DSviewer)
==7833==    by 0x4CA9F9: alpha_blend(Fl_RGB_Image*, int, int, int, int,
int, int) (Fl_Image.cxx:387)
==7833==    by 0x4CB2BE: Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image*, int,
int, int, int, int, int) (Fl_Image.cxx:573)
==7833==    by 0x4CAD2A: Fl_RGB_Image::draw(int, int, int, int, int, int)
(Fl_Image.cxx:438)
==7833==    by 0x4BDE35: Fl_Image::draw(int, int) (Fl_Image.H:160)
==7833==    by 0x5004D8: fl_draw(char const*, int, int, int, int, unsigned
int, void (*)(char const*, int, int, int), Fl_Image*, int) (fl_d
==7833==    by 0x500D0C: fl_draw(char const*, int, int, int, int, unsigned
int, Fl_Image*, int) (fl_draw.cxx:386)
==7833==    by 0x5065F0: fl_normal_label(Fl_Label const*, int, int, int,
int, unsigned int) (fl_labeltype.cxx:46)
==7833==    by 0x50674C: Fl_Label::draw(int, int, int, int, unsigned int)
const (fl_labeltype.cxx:88)
==7833==    by 0x506A18: Fl_Widget::draw_label(int, int, int, int,
unsigned int) const (fl_labeltype.cxx:134)


Link: http://www.fltk.org/str.php?L2637
Version: 1.3.0
diff -ur fltk-1.3.0rc5-orig//src/Fl_Image.cxx 
fltk-1.3.0rc5-new//src/Fl_Image.cxx
--- fltk-1.3.0rc5-orig//src/Fl_Image.cxx        2011-04-20 09:01:04.000000000 
-0500
+++ fltk-1.3.0rc5-new//src/Fl_Image.cxx 2011-05-19 14:10:16.000000000 -0500
@@ -384,7 +384,7 @@
   uchar *srcptr = (uchar*)img->array + cy * ld + cx * img->d();
   int srcskip = ld - img->d() * W;
 
-  uchar *dst = new uchar[W * H * 3];
+  uchar *dst = new uchar[((W * H * 3) + 15) & (~7)];
   uchar *dstptr = dst;
 
   fl_read_image(dst, X, Y, W, H, 0);
diff -ur fltk-1.3.0rc5-orig//src/screen_xywh.cxx 
fltk-1.3.0rc5-new//src/screen_xywh.cxx
--- fltk-1.3.0rc5-orig//src/screen_xywh.cxx     2011-04-22 12:30:37.000000000 
-0500
+++ fltk-1.3.0rc5-new//src/screen_xywh.cxx      2011-05-19 14:10:16.000000000 
-0500
@@ -151,9 +151,12 @@
   if (XineramaIsActive(fl_display)) {
     screens = XineramaQueryScreens(fl_display, &num_screens);
     int i;
+    // Xlib and Xinerama may disagree on the screen count. Sigh...
+    // Use the minimum of the reported counts.
+    // Use the previous screen's info for non-existent ones.
     for (i=0; i<num_screens; i++) {
-      int mm = DisplayWidthMM(fl_display, i);
-      dpi[i][0] = mm ? screens[i].width*25.4f/mm : 0.0f;
+      int mm = (i < ScreenCount(fl_display)) ? DisplayWidthMM(fl_display, i) : 
0;
+      dpi[i][0] = mm ? screens[i].width*25.4f/mm : (i > 0) ? dpi[i-1][0] : 
0.0f;
       mm = DisplayHeightMM(fl_display, fl_screen);
       dpi[i][1] = mm ? screens[i].height*25.4f/mm : dpi[i][0];
     }
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to