diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2021-10-06 17:35:07 +0300 | 
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-10-06 19:13:12 +0300 | 
| commit | 72618ba82af966bbde6fda49905f6b2b6fa25fd0 (patch) | |
| tree | ed7d02431871bec8d4b56342e9220350b108ee0c /lib/vector.c | |
| parent | 3f220bc814abeb11a17fad80f14c7ba79af67429 (diff) | |
lib: fix incorrect thread management
The current code passes an address of a local variable to `thread_add_read`
which stores it into `thread->ref` by the lib. The next time the thread
callback is executed, the lib stores NULL into the `thread->ref` which
means it writes into some random memory on the stack.
To fix this, we should pass a pointer to the vector entry to the lib.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/vector.c')
| -rw-r--r-- | lib/vector.c | 11 | 
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/vector.c b/lib/vector.c index 565c49fd59..4af564a82f 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -123,6 +123,17 @@ int vector_set_index(vector v, unsigned int i, void *val)  	return i;  } +/* Make a specified index slot active and return its address. */ +void **vector_get_index(vector v, unsigned int i) +{ +	vector_ensure(v, i); + +	if (v->active <= i) +		v->active = i + 1; + +	return &v->index[i]; +} +  /* Look up vector.  */  void *vector_lookup(vector v, unsigned int i)  {  | 
