[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/6] Check return value of pk_str_concat
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH 1/6] Check return value of pk_str_concat |
Date: |
Thu, 07 May 2020 18:37:20 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi Tim.
diff --git a/libpoke/pkl.c b/libpoke/pkl.c
index 3b6ae369..aeb6ecc9 100644
--- a/libpoke/pkl.c
+++ b/libpoke/pkl.c
@@ -79,6 +79,16 @@ pkl_new (pvm vm, const char *rt_path)
error and should be reported as such. */
{
char *poke_rt_pk = pk_str_concat (rt_path, "/pkl-rt.pk", NULL);
+ if (!poke_rt_pk)
+ {
+out_of_memory:
+ pk_term_class ("error");
+ pk_puts ("error: ");
+ pk_term_end_class ("error");
+ pk_puts ("out of memory\n");
+
+ return NULL;
+ }
if (!pkl_compile_file (compiler, poke_rt_pk))
{
@@ -97,6 +107,8 @@ pkl_new (pvm vm, const char *rt_path)
/* Load the standard library. */
{
char *poke_std_pk = pk_str_concat (rt_path, "/std.pk", NULL);
+ if (!poke_std_pk)
+ goto out_of_memory;
if (!pkl_compile_file (compiler, poke_std_pk))
return NULL;
I would prefer if you would move the out_of_memory label to the end of
the pkl_new function, after `return_compiler'.
Other than that this is OK.
- Re: [PATCH 3/6] ios: Check ios->handler_normalize for memory allocation error., (continued)
[PATCH 4/6] poke: Add new function pk_assert_alloc, Tim Rühsen, 2020/05/07
[PATCH 5/6] poke: Remove unneeded header includes., Tim Rühsen, 2020/05/07
[PATCH 6/6] ios: Amend OOM message to be consistent everywhere., Tim Rühsen, 2020/05/07
Re: [PATCH 1/6] Check return value of pk_str_concat,
Jose E. Marchesi <=