mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
2 changed files with 12 additions and 2 deletions
|
@ -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>
|
||||
|
||||
* 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;
|
||||
|
||||
tmp = xmalloc(len);
|
||||
if (tmp == NULL) return NULL;
|
||||
memcpy(tmp, str, len);
|
||||
|
||||
return tmp;
|
||||
|
@ -643,7 +642,10 @@ ruby_getcwd()
|
|||
char *buf = xmalloc(size);
|
||||
|
||||
while (!getcwd(buf, size)) {
|
||||
if (errno != ERANGE) rb_sys_fail("getcwd");
|
||||
if (errno != ERANGE) {
|
||||
free(buf);
|
||||
rb_sys_fail("getcwd");
|
||||
}
|
||||
size *= 2;
|
||||
buf = xrealloc(buf, size);
|
||||
}
|
||||
|
@ -654,6 +656,7 @@ ruby_getcwd()
|
|||
char *buf = xmalloc(PATH_MAX+1);
|
||||
|
||||
if (!getwd(buf)) {
|
||||
free(buf);
|
||||
rb_sys_fail("getwd");
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue