Bug 118837 - [patch] getdata: memory leak on getdata error
Summary: [patch] getdata: memory leak on getdata error
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-22 04:26 UTC by D. V. Wiebe
Modified: 2005-12-22 05:08 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
memory leak patch for getdata (762 bytes, patch)
2005-12-22 04:27 UTC, D. V. Wiebe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description D. V. Wiebe 2005-12-22 04:26:50 UTC
Version:           1.2.0_devel (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources
Compiler:          gcc (GCC) 3.4.4 
OS:                Linux

The following patch fixes a memory leak which occurs if getdata encounters an error when it tries to read the second field of a lincom or multiply.  In these cases, the temporary buffer allocated for the second field is not properly freed before the error is reported.
Comment 1 D. V. Wiebe 2005-12-22 04:27:18 UTC
Created attachment 14017 [details]
memory leak patch for getdata
Comment 2 George Staikos 2005-12-22 05:08:05 UTC
SVN commit 490483 by staikos:

fix memory leak and assertion failure.  Patches from Don
BUGS: 118837, 118838


 M  +21 -4     getdata.c  


--- trunk/extragear/graphics/kst/kst/datasources/dirfile/getdata.c #490482:490483
@@ -1201,7 +1201,14 @@
       error_code);
 
   recurse_level--;
-  if (*error_code != GD_E_OK) return(1);
+
+  if (*error_code != GD_E_OK)
+    return(1);
+
+  /* Nothing to lincomise */
+  if (*n_read == 0)
+    return 1;
+  
   ScaleData(data_out, return_type, *n_read, L->m[0], L->b[0]);
 
   if (L->n_infields > 1) {
@@ -1230,8 +1237,10 @@
           return_type, tmpbuf,
           error_code);
       recurse_level--;
-      if (*error_code != GD_E_OK)
+      if (*error_code != GD_E_OK) {
+        free(tmpbuf);
         return(1);
+      }
 
       ScaleData(tmpbuf, return_type, n_read2, L->m[i], L->b[i]);
 
@@ -1290,8 +1299,14 @@
       error_code);
 
   recurse_level--;
-  if (*error_code != GD_E_OK) return(1);
 
+  if (*error_code != GD_E_OK)
+    return 1;
+
+  /* Nothing to multiply */
+  if (*n_read == 0)
+    return 1;
+
   recurse_level++;
 
   /* find the samples per frame of the second field */
@@ -1316,8 +1331,10 @@
       return_type, tmpbuf,
       error_code);
   recurse_level--;
-  if (*error_code != GD_E_OK)
+  if (*error_code != GD_E_OK) {
+    free(tmpbuf);
     return(1);
+  }
 
   if (n_read2 > 0 && n_read2 * spf1 < *n_read * spf2) {
     *n_read = n_read2 * spf1 / spf2;