File: fix-memory-leak-on-realloc.patch

package info (click to toggle)
das-watchdog 0.9.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 252 kB
  • sloc: ansic: 3,280; sh: 60; makefile: 48
file content (23 lines) | stat: -rw-r--r-- 566 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Description: Fix memory leak on realloc
Origin: vendor
Author: Salvatore Bonaccorso <carnil@debian.org>
Last-Update: 2015-04-11

--- a/das_watchdog.c
+++ b/das_watchdog.c
@@ -325,7 +325,14 @@ static char *get_pid_environ_val(pid_t p
 
     if (i >= temp_size) {
       temp_size *= 2;
-      temp = realloc(temp, temp_size);
+      char *new_temp = realloc(temp, temp_size);
+      if(new_temp==NULL){
+        fclose(fp);
+        free(temp);
+        return NULL;
+      }else{
+        temp=new_temp;
+      }
     }
 
     if(foundit==1 && (c=='\0' || c==EOF)){