aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/spawn.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2021-06-04 01:17:38 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2021-06-04 01:30:18 +0200
commit5167dad198508e2dac10bf89c6b2991cfc791ee6 (patch)
tree7dbab3e7047ce80e6651f238f95d241a6a460ad1 /src/spawn.c
parentad392b343a59c6bd093a2bd352598f6e7747828e (diff)
downloadsciteco-5167dad198508e2dac10bf89c6b2991cfc791ee6.tar.gz
guard against too low arguments to <S> by checking whether the memory limit would be exceeded
* Checking whether the allocation succeeded may not prevent exceeding the memory limit excessively. * Even if the memory limit is not exceeded, the allocation can fail theoretically and the program would terminate abnormally. This however is true for all allocations in SciTECO (via glib). * teco_memory_check() therefore now supports checking whether an allocation would exceed the memory limit which will be useful before very large or variable allocations in addition to the regular checking in teco_machine_main_step(). * As a sideeffect, this fixes the "Searching with large counts" test case on Mac OS where too large allocations were not detected as expected (apparently Mac OS happily gives out ridiculously large chunks of memory). Now, all platforms are guaranteed to have the same behaviour.
Diffstat (limited to 'src/spawn.c')
-rw-r--r--src/spawn.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/spawn.c b/src/spawn.c
index 1406731..00ff3ad 100644
--- a/src/spawn.c
+++ b/src/spawn.c
@@ -640,10 +640,11 @@ teco_spawn_stdout_watch_cb(GIOChannel *chan, GIOCondition condition, gpointer da
teco_spawn_ctx.text_added = TRUE;
/*
- * NOTE: Since this reads from an external process, we could insert
+ * NOTE: Since this reads from an external process and regular memory
+ * limiting in teco_machine_main_step() is not performed, we could insert
* indefinitely (eg. cat /dev/zero).
*/
- if (!teco_memory_check(&teco_spawn_ctx.error))
+ if (!teco_memory_check(0, &teco_spawn_ctx.error))
goto error;
}