Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh/example readonly array parameter



On Feb 10,  2:15pm, Sebastian Gniazdowski wrote:
}
} How to make int and array parameters (defined via paramdef structure)
} read-only?

To answer what was asked:

    PARAMDEF("exarr", PM_ARRAY|PM_READONLY, &arrparam, NULL);

However ...

} # unset exarr
} 
} # example a b c
}  utils.c:3896: freearray() with zero argument
} zsh: segmentation fault  zsh-5.3.1-dev-0

... this is just the example module being stupid.

diff --git a/Src/Modules/example.c b/Src/Modules/example.c
index 45ca2cf..c80c9e7 100644
--- a/Src/Modules/example.c
+++ b/Src/Modules/example.c
@@ -69,7 +69,8 @@ bin_example(char *nam, char **args, Options ops, UNUSED(int func))
     intparam = i;
     zsfree(strparam);
     strparam = ztrdup(*oargs ? *oargs : "");
-    freearray(arrparam);
+    if (arrparam)
+	freearray(arrparam);
     arrparam = zarrdup(oargs);
     return 0;
 }



Messages sorted by: Reverse Date, Date, Thread, Author