Commit graph

14 commits

Author SHA1 Message Date
Adygzhy Ondar
1911acb84f tvm_vm_create(): fix possible NULL pointer dereferencing.
if calloc() doesn't allocate memory for struct tvm_ctx,
there may be NULL pointer dereferencing, i.e. vm->mem, vm->prog.
So the vm pointer verification must be before it is used.

Also, there is the same situation with vm->mem and stack creation.
2017-10-28 14:00:01 +03:00
Adygzhy Ondar
d7d74e6999 tvm_vm_create(): filename parameter is removed. 2017-10-28 13:59:18 +03:00
Joseph Kogut
488b88f867 tvm_preprocess: update *src after (re)allocating memory
During preprocessing, we find directives, and if they specify including
other source files, we remove the directive, allocate a new block of
memory, copy the first block, append the new source file, and append the
second block.

Previously, the value of the source pointer was passed into the
preprocessing function. When the memory would be (re)allocated, the
pointer value could change, but the original pointer would not be
updated.

Now, the pointer is passed by address, and updated when the memory it
points to changes.
2017-02-12 11:51:06 -08:00
Joseph Kogut
ca87b3c5e9 Refactor with a consistent coding style
This commit refactors the project using a single, consistent coding
style, derived from the Linux Kernel Coding Style, available here:

https://www.kernel.org/doc/Documentation/CodingStyle

This includes, but is not limited to:
* Removal of typedefs, especially for structs
* Limiting lines to a reasonable length, 80 characters, mostly
* K&R style braces
* Removal of CamelCase
2016-08-28 20:31:12 -07:00
Joseph Kogut
d5ed7e75d9 * Replaced all instances of malloc with calloc
* Replaced magic number in tvm_htab.c with define
2013-03-07 12:19:03 -07:00
Joseph Kogut
ed3acfd515 Made naming conventions more consistent. 2013-01-23 11:15:07 -07:00
Joseph Kogut
d270cc5706 Made pointer syntax consistent 2013-01-23 11:06:19 -07:00
Joseph Kogut
caf4767696 Inlined tvm_step() and htab_hash(). 2013-01-23 10:41:17 -07:00
Joseph Kogut
19ec55c301 Fixed comment mix up 2011-10-07 13:14:47 -07:00
bl0ckeduser
fcd0a1f7e2 Fix bug in "ret" opcode 2011-10-07 14:38:18 -04:00
Joseph Kogut
72193566b9 Moved program interpretation to explicitly called function 2011-09-25 05:47:31 -07:00
Joseph Kogut
75edb60116 * Fixed a style issue
* Inlined tvm_step()
2011-09-04 18:45:56 -07:00
Patrick Jackson
68d066bd53 Removed the redundancy introduced by tdb_step. 2011-09-04 17:06:08 -04:00
Joseph Kogut
15019d041f * Moved TVM code to an independent library
* Moved interpreter code to tvmi.c
2011-08-26 15:30:24 -07:00
Renamed from tvm.c (Browse further)