Le 15/12/2012 08:35, Carsten Haitzler (The Rasterman) a écrit :
> because i didnt use your patch at all - i just fixed the file leak that it
> pointed out. mike asked for you to provie a new patch against current as i
> assume it didnt apply... so i just fixed the bug there.

I don't know if you noticed, but I sent a patch before your answer.


-------- Message original --------
Sujet: Re: [E-devel] [e] [patch] Leak (was FreeBSD patch)
Date : Sat, 15 Dec 2012 08:43:03 +0100
De : Maxime Villard <rusty...@gmx.fr>
Répondre à : Enlightenment developer list 
<enlightenment-devel@lists.sourceforge.net>
Pour : enlightenment-devel@lists.sourceforge.net

Le 15/12/2012 08:19, Maxime Villard a écrit :
> Le 14/12/2012 06:29, Carsten Haitzler (The Rasterman) a écrit :
>> > i put in just fixed for the FILE * leak here on error -
>> > the rest i kept.
> Why ?

I would also move some {free(x); x = null} to E_FREE.

Patch joined.




--- tempget.c	2012-12-15 08:37:40.208994605 +0100
+++ tempget.c	2012-12-15 08:33:10.431144241 +0100
@@ -426,7 +426,6 @@
              if (fgets(buf, sizeof(buf), f) == NULL) goto error;
              fclose(f);
              f = NULL;
-             buf[sizeof(buf) - 1] = 0;
              if (sscanf(buf, "%s %s %i", dummy, dummy, &temp) == 3)
                ret = 1;
              else
@@ -444,7 +443,6 @@
              if (fgets(buf, sizeof(buf), f) == NULL) goto error;
              fclose(f);
              f = NULL;
-             buf[sizeof(buf) - 1] = 0;
              if (sscanf(buf, "%i", &temp) == 1)
                ret = 1;
              else
@@ -463,7 +461,6 @@
              if (fgets(buf, sizeof(buf), f) == NULL) goto error;
              fclose(f);
              f = NULL;
-             buf[sizeof(buf) - 1] = 0;
              /* actually read the temp */
              if (sscanf(buf, "%i", &temp) == 1)
                ret = 1;
@@ -483,7 +480,6 @@
              if (fgets(buf, sizeof(buf), f) == NULL) goto error;
              fclose(f);
              f = NULL;
-             buf[sizeof(buf) - 1] = 0;
              /* actually read the temp */
              if (sscanf(buf, "%i", &temp) == 1)
                ret = 1;
@@ -505,7 +501,6 @@
              if (fgets(buf, sizeof(buf), f) == NULL) goto error;
              fclose(f);
              f = NULL;
-             buf[sizeof(buf) - 1] = 0;
              p = strchr(buf, ':');
              if (p)
                {
@@ -531,7 +526,6 @@
              if (fgets(buf, sizeof(buf), f) == NULL) goto error;
              fclose(f);
              f = NULL;
-             buf[sizeof(buf) - 1] = 0;
              temp = atoi(buf);
              temp /= 1000;
              ret = 1;
@@ -549,12 +543,9 @@
    return -999;
 error:
    if (f) fclose(f);
-   f = NULL;
    sensor_type = SENSOR_TYPE_NONE;
-   if (sensor_name) free(sensor_name);
-   sensor_name = NULL;
-   if (sensor_path) free(sensor_path);
-   sensor_path = NULL;
+   E_FREE(sensor_name);
+   E_FREE(sensor_path);
    return -999;
 }
 


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to