Menu

#30 Missing initialization of fieldblock in defineClass

open
nobody
None
5
2008-03-03
2008-03-03
No

Running valgrind on jamvm 1.5.0 (classpath 0.97) with a simple hello world application produces this error:

==22513== Conditional jump or move depends on uninitialised value(s)
==22513== at 0x8050238: linkClass (class.c:1012)
==22513== by 0x8051E07: findSystemClass0 (class.c:1270)
==22513== by 0x80526FA: findClassFromClassLoader (class.c:1382)
==22513== by 0x805E6D2: resolveClass (resolve.c:110)
==22513== by 0x8051AC4: defineClass (class.c:536)
==22513== by 0x8051CEA: loadSystemClass (class.c:1218)
==22513== by 0x8051E11: findSystemClass0 (class.c:1267)
==22513== by 0x80526FA: findClassFromClassLoader (class.c:1382)
==22513== by 0x805E6D2: resolveClass (resolve.c:110)
==22513== by 0x8051AC4: defineClass (class.c:536)
==22513== by 0x8051CEA: loadSystemClass (class.c:1218)
==22513== by 0x8051E11: findSystemClass0 (class.c:1267)
==22513==

The following patch fixes it:

diff -Naur jamvm-1.5.0/src/class.c jamvm-1.5.0.patched/src/class.c
--- jamvm-1.5.0/src/class.c 2007-10-29 05:45:32.000000000 +0100
+++ jamvm-1.5.0.patched/src/class.c 2008-03-03 11:49:59.000000000 +0100
@@ -302,6 +302,7 @@
classblock->fields[i].annotations = NULL;
classblock->fields[i].signature = NULL;
classblock->fields[i].constant = 0;
+ classblock->fields[i].offset = 0;

READ_U2(attr_count, ptr, len);
for(; attr_count != 0; attr_count--) {

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.