changeset 1998:cc7e5d469d1b

Protect uw_Basis_new_client_source from invalid ctx->id We assume that FFI code may create new contextes with id left unassigned
author Sergey Mironov <grrwlf@gmail.com>
date Wed, 26 Feb 2014 09:43:47 +0000
parents c93fbd139732
children a1d3fbdcc897
files src/c/urweb.c
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/c/urweb.c	Wed Feb 26 08:21:52 2014 +0000
+++ b/src/c/urweb.c	Wed Feb 26 09:43:47 2014 +0000
@@ -1586,6 +1586,9 @@
   int len;
   size_t s_len = strlen(s);
 
+  if(ctx->id < 0)
+    uw_error(ctx, FATAL, "Attempt to create client source using inappropriate context");
+
   uw_check_script(ctx, 15 + 2 * INTS_MAX + s_len);
   sprintf(ctx->script.front, "s%d_%llu=sc(exec(%n", ctx->id, ctx->source_count, &len);
   ctx->script.front += len;