[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-core
Subject: [Patch] String and (repost) MemLeak
From: Michal Rokos <michal () rokos ! homeip ! net>
Date: 2003-02-28 20:47:30
[Download RAW message or body]
Hi,
1 memleak hasn't been fixed - I (still) think that there could be a
problem... (REPOSTING)
Index: dir.c
===================================================================
RCS file: /src/ruby/dir.c,v
retrieving revision 1.82
diff -u -p -r1.82 dir.c
--- dir.c 16 Jan 2003 07:34:01 -0000 1.82
+++ dir.c 28 Jan 2003 18:24:39 -0000
@@ -778,6 +778,7 @@ glob_helper(path, sub, flags, func, arg)
sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "",
dp->d_name);
if (lstat(buf, &st) < 0) {
if (errno != ENOENT) rb_sys_warning(buf);
+ free(buf);
continue;
}
if (S_ISDIR(st.st_mode)) {
And I've seen that Matz removed MEMZERO(), but I think there could be a
problem with ->len...
Index: string.c
===================================================================
RCS file: /src/ruby/string.c,v
retrieving revision 1.147
diff -u -p -r1.147 string.c
--- string.c 27 Feb 2003 08:04:32 -0000 1.147
+++ string.c 28 Feb 2003 20:40:42 -0000
@@ -64,12 +64,15 @@ str_new(klass, ptr, len)
}
str = str_alloc(klass);
- RSTRING(str)->len = len;
RSTRING(str)->aux.capa = len;
RSTRING(str)->ptr = ALLOC_N(char,len+1);
if (ptr) {
memcpy(RSTRING(str)->ptr, ptr, len);
}
+ else {
+ len = 0;
+ }
+ RSTRING(str)->len = len;
RSTRING(str)->ptr[len] = '\0';
return str;
}
Any comments? Are my doubts odd?
Michal
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic