[xloadimage/f17] fix memory leak, enable support for sub-second delay

Tom Callaway spot at fedoraproject.org
Wed Jan 2 18:27:33 UTC 2013


commit 8cbd6224532db276f856956513a6edfbd03385e5
Author: Tom Callaway <spot at fedoraproject.org>
Date:   Wed Jan 2 13:29:29 2013 -0500

    fix memory leak, enable support for sub-second delay

 xloadimage-4.1-fix-mem-leak.patch     |   12 ++++++++
 xloadimage-4.1-sub-second-delay.patch |   51 +++++++++++++++++++++++++++++++++
 xloadimage.spec                       |   12 +++++++-
 3 files changed, 74 insertions(+), 1 deletions(-)
---
diff --git a/xloadimage-4.1-fix-mem-leak.patch b/xloadimage-4.1-fix-mem-leak.patch
new file mode 100644
index 0000000..63a2c53
--- /dev/null
+++ b/xloadimage-4.1-fix-mem-leak.patch
@@ -0,0 +1,12 @@
+diff -up xloadimage.4.1/new.c.fix-mem-leak xloadimage.4.1/new.c
+--- xloadimage.4.1/new.c.fix-mem-leak	2013-01-02 13:21:24.082069878 -0500
++++ xloadimage.4.1/new.c	2013-01-02 13:22:04.427104519 -0500
+@@ -181,7 +181,7 @@ Image *newTrueImage(width, height)
+   image->depth= 24;
+   image->pixlen= 3;
+   image->data= (unsigned char *)lmalloc(ovmul(ovmul(width, height), 3));
+-  image->data= (unsigned char *)lmalloc(width * height * 3);
++  /* image->data= (unsigned char *)lmalloc(width * height * 3); */
+   return(image);
+ }
+ 
diff --git a/xloadimage-4.1-sub-second-delay.patch b/xloadimage-4.1-sub-second-delay.patch
new file mode 100644
index 0000000..50a88b5
--- /dev/null
+++ b/xloadimage-4.1-sub-second-delay.patch
@@ -0,0 +1,51 @@
+diff -up xloadimage.4.1/options.c.sub-second-delay xloadimage.4.1/options.c
+--- xloadimage.4.1/options.c.sub-second-delay	2013-01-02 13:23:23.726173587 -0500
++++ xloadimage.4.1/options.c	2013-01-02 13:23:37.706185351 -0500
+@@ -720,7 +720,7 @@ void processOptions(argc, argv, rglobal,
+       
+       continue;
+ #else /* !NO_DELAY */
+-      newopt->info.delay= getInteger(DELAY, argv[a]);
++      newopt->info.delay= getFloat(DELAY, argv[a]);
+       break;
+ #endif /* !NO_DELAY */
+ 
+diff -up xloadimage.4.1/options.h.sub-second-delay xloadimage.4.1/options.h
+--- xloadimage.4.1/options.h.sub-second-delay	2013-01-02 13:25:44.297294626 -0500
++++ xloadimage.4.1/options.h	2013-01-02 13:26:25.338329430 -0500
+@@ -49,7 +49,7 @@ typedef struct option {
+       unsigned int x, y, w, h; /* area of image to be used */
+     } clip;
+     unsigned int  colors;     /* max # of colors to use for this image */
+-    unsigned int  delay;      /* # of seconds delay before auto pic advance */
++    double  delay;            /* # of seconds delay before auto pic advance */
+     char         *display;    /* display name */
+     struct {
+       char *type; /* image type */
+diff -up xloadimage.4.1/window.c.sub-second-delay xloadimage.4.1/window.c
+--- xloadimage.4.1/window.c.sub-second-delay	2013-01-02 13:24:13.903216792 -0500
++++ xloadimage.4.1/window.c	2013-01-02 13:25:35.928287337 -0500
+@@ -583,9 +583,9 @@ char imageInWindow(disp, scrn, image, gl
+   install= (getOption(global_options, INSTALL) != NULL);
+   private_cmap= (getOption(global_options, PRIVATE) != NULL);
+   if ((opt= getOption(image_options, DELAY)))
+-    delay= opt->info.delay;
++    delay= opt->info.delay*1000000;
+   else if ((opt= getOption(global_options, DELAY)))
+-    delay= opt->info.delay;
++    delay= opt->info.delay*1000000;
+   else
+     delay= 0;
+   if ((opt= getOption(image_options, VISUAL)))
+@@ -872,7 +872,10 @@ char imageInWindow(disp, scrn, image, gl
+ #ifdef ENABLE_TIMEOUT
+       AlarmWentOff = 0;
+       signal(SIGALRM, delayAlarmHandler);
+-      alarm(delay);
++      if (delay > 999999)
++	alarm(delay/1000000);
++      else
++	ualarm(delay,0);
+ #endif /* ENABLE_TIMEOUT */
+   }
+ 
diff --git a/xloadimage.spec b/xloadimage.spec
index 4a3f60c..686a474 100644
--- a/xloadimage.spec
+++ b/xloadimage.spec
@@ -1,7 +1,7 @@
 Name:		xloadimage
 Summary: 	Image viewer and processor
 Version:	4.1
-Release:	12%{?dist}
+Release:	13%{?dist}
 License:	MIT
 Group:		User Interface/X
 Source0:	ftp://ftp.x.org/R5contrib/%{name}.%{version}.tar.gz
@@ -31,6 +31,8 @@ Patch20:	xloadimage-4.1-bracketfix.patch
 Patch21:	xloadimage-4.1-png-pkg-config.patch
 Patch22:	xloadimage-4.1-libtiff4.patch
 Patch23:	xloadimage-4.1-png-1.5.patch
+Patch24:	xloadimage-4.1-fix-mem-leak.patch
+Patch25:	xloadimage-4.1-sub-second-delay.patch
 URL:		http://www.frostbytes.com/~jimf/xloadimage.html
 %if 0%{?fedora} >= 18
 BuildRequires:	libtiff-devel >= 4.0
@@ -81,6 +83,9 @@ dithered automatically).
 %patch22 -p1 -b .tiff4
 %endif
 %patch23 -p1 -b .png15
+%patch24 -p1 -b .fix-mem-leak
+%patch25 -p1 -b .sub-second-delay
+
 chmod +x configure
 
 %build
@@ -119,6 +124,11 @@ cp -a %{buildroot}%{_mandir}/man1/xloadimage.1x %{buildroot}%{_mandir}/man1/xvie
 %{_mandir}/man1/*
 
 %changelog
+* Wed Jan  2 2013 Tom Callaway <spot at fedoraproject.org> - 4.1-13
+- fix memory leak caused by opening a lot of files at once then cycling through them with "N"
+- enable support for sub-second-delay values
+- thanks to Roger Heflin for both patches
+
 * Tue Nov 27 2012 Tom Callaway <spot at fedoraproject.org> - 4.1-12
 - fix png 1.5 support
 


More information about the scm-commits mailing list