* util.c (ruby_strdup): remove unnecessary code. (xmalloc never
returns NULL.) * util.c (ruby_getcwd): fix memory leak on failure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4ad01cad01
commit
d7da08aadd
@ -1,3 +1,10 @@
|
|||||||
|
Sun Sep 12 23:53:17 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
|
* util.c (ruby_strdup): remove unnecessary code. (xmalloc never
|
||||||
|
returns NULL.)
|
||||||
|
|
||||||
|
* util.c (ruby_getcwd): fix memory leak on failure.
|
||||||
|
|
||||||
Sun Sep 12 02:41:58 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
Sun Sep 12 02:41:58 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
* ext/tcltklib/tcltklib.c: add TclTkIp#allow_ruby_exit? and
|
* ext/tcltklib/tcltklib.c: add TclTkIp#allow_ruby_exit? and
|
||||||
|
7
util.c
7
util.c
@ -629,7 +629,6 @@ ruby_strdup(str)
|
|||||||
int len = strlen(str) + 1;
|
int len = strlen(str) + 1;
|
||||||
|
|
||||||
tmp = xmalloc(len);
|
tmp = xmalloc(len);
|
||||||
if (tmp == NULL) return NULL;
|
|
||||||
memcpy(tmp, str, len);
|
memcpy(tmp, str, len);
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
@ -643,7 +642,10 @@ ruby_getcwd()
|
|||||||
char *buf = xmalloc(size);
|
char *buf = xmalloc(size);
|
||||||
|
|
||||||
while (!getcwd(buf, size)) {
|
while (!getcwd(buf, size)) {
|
||||||
if (errno != ERANGE) rb_sys_fail("getcwd");
|
if (errno != ERANGE) {
|
||||||
|
free(buf);
|
||||||
|
rb_sys_fail("getcwd");
|
||||||
|
}
|
||||||
size *= 2;
|
size *= 2;
|
||||||
buf = xrealloc(buf, size);
|
buf = xrealloc(buf, size);
|
||||||
}
|
}
|
||||||
@ -654,6 +656,7 @@ ruby_getcwd()
|
|||||||
char *buf = xmalloc(PATH_MAX+1);
|
char *buf = xmalloc(PATH_MAX+1);
|
||||||
|
|
||||||
if (!getwd(buf)) {
|
if (!getwd(buf)) {
|
||||||
|
free(buf);
|
||||||
rb_sys_fail("getwd");
|
rb_sys_fail("getwd");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user