[#290] — Florian Frank <flori@...>
Hi all,
5 messages
2002/08/03
[#297] GC longjmp macros — Michal Rokos <m.rokos@...>
Hi,
5 messages
2002/08/05
[#308] Q: OSSL in std. distr? — Michal Rokos <m.rokos@...>
Hi,
4 messages
2002/08/08
[#326] Implications of a #force_free method in Object? — Matthew Bloch <mattbee@...>
Hello;
8 messages
2002/08/19
[#328] Int vs Long — Michal Rokos <m.rokos@...>
Hi,
7 messages
2002/08/21
[#337] Int vs Long (2nd part) — Michal Rokos <m.rokos@...>
Hi,
7 messages
2002/08/22
[#340] Int vs Long #3 — Michal Rokos <m.rokos@...>
Hi,
9 messages
2002/08/22
[#344] Re: [Cleanup] Int vs Long #3
— nobu.nokada@...
2002/08/22
Hi,
[#348] Re: [Cleanup] Int vs Long #3
— Michal Rokos <m.rokos@...>
2002/08/23
Hello,
[#353] File (struct stat handling) — Michal Rokos <m.rokos@...>
Hello,
6 messages
2002/08/23
[#358] node.h for eval.c — Michal Rokos <m.rokos@...>
Hi,
5 messages
2002/08/23
[#372] rb_class_path — Michal Rokos <m.rokos@...>
Hello,
7 messages
2002/08/27
[#382] Port match to new dup, clone framework — Michal Rokos <m.rokos@...>
Hi,
5 messages
2002/08/28
[#393] in dln.c — Michal Rokos <m.rokos@...>
Hi,
14 messages
2002/08/30
[#398] Re: [MemLeak] in dln.c
— nobu.nokada@...
2002/08/31
Hi,
[#403] Re: [MemLeak] in dln.c
— Michal Rokos <m.rokos@...>
2002/09/02
Hello,
[Cleanup?] File (struct stat handling)
From:
Michal Rokos <m.rokos@...>
Date:
2002-08-23 12:56:02 UTC
List:
ruby-core #353
Hello,
when I tried to track down all remaining off_t leftovers, I saw
(at least I think) not so safe struct stat handling.
Could you look at it?
Thank you.
Michal
PS: Don't worry - no more patches are comming (It's weekend and
BankHoliday monday) :-)
Index: file.c
===================================================================
RCS file: /src/ruby/file.c,v
retrieving revision 1.105
diff -u -p -r1.105 file.c
--- file.c 2002/08/21 15:47:54 1.105
+++ file.c 2002/08/23 12:46:08
@@ -122,7 +122,7 @@ stat_new_0(klass, st)
if (st) {
nst = ALLOC(struct stat);
- *nst = *st;
+ memcpy(nst, st, sizeof(struct stat));
}
return Data_Wrap_Struct(klass, NULL, free, nst);
}
@@ -2007,8 +2007,12 @@ rb_stat_init(obj, fname)
if (stat(RSTRING(fname)->ptr, &st) == -1) {
rb_sys_fail(RSTRING(fname)->ptr);
}
+ if (DATA_PTR(obj)) {
+ free(DATA_PTR(obj));
+ DATA_PTR(obj) = NULL;
+ }
nst = ALLOC(struct stat);
- *nst = st;
+ memcpy(nst, &st, sizeof(struct stat));
DATA_PTR(obj) = nst;
return Qnil;
@@ -2024,12 +2028,11 @@ rb_stat_clone(obj)
clone = rb_obj_alloc(RBASIC(obj)->klass);
CLONESETUP(clone,obj);
+
if (DATA_PTR(obj)) {
nst = ALLOC(struct stat);
- *nst = *(struct stat*)DATA_PTR(obj);
- DATA_PTR(clone) = nst;
+ memcpy(DATA_PTR(clone), DATA_PTR(obj), sizeof(struct stat));
}
-
return clone;
}
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos Czech Technical University, Prague
E-mail:m.rokos@sh.cvut.cz ICQ:36118339 Jabber:majkl@jabber.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-