On 1/17/19 6:58 PM, luigi scarso wrote:
> On Wed, Jan 16, 2019 at 11:04 PM Henri Menke <[email protected]> wrote:
>
>> The fix is pretty easy, there was only an uninitialized string
>> somewhere. Patch is attached.
>>
>> On 16/01/19 10:51 PM, luigi scarso wrote:
>> > On Wed, Jan 16, 2019 at 10:45 AM Henri Menke <[email protected]>
>> wrote:
>> >
>> >> I have prepared a plain example (attached) which can be run with
>> >>
>> >> mtxrun --script plain --run test.tex
>> >>
>> >> and also segfaults.
>> >>
>> >> On 1/16/19 10:14 PM, Henri Menke wrote:
>> >>> Dear list,
>> >>>
>> >>> To answer a question on TeX.SX I wanted to compare glyph sidebearings
>> >>> using kerns. However, when trying to insert a kern before the head of
>> >>> the last line I first get an error followed by segmentation fault:
>> >>>
>> >>> warning (node filter): error: [\directlua]:12: Attempt to
>> >>> node.insert_before() a non-existing node
>> >>>
>> >>> Segmentation fault
>> >>>
>> >>> The example is attached because it's a bit larger. I marked the
>> >>> offending line with “BOOM”.
>> >>>
>> >>> Cheers, Henri
>> >>>
>> >>
>> >>
>> > Thank you very much for the report, we will see it asap.
>> >
>>
>
> $ cat test-053.c
> /*test-053.c */
> int main(void)
> {
> char *a ="";
> (void)a;
> return 0;
>
> }
> $ gcc -Wall -Wextra -Wunused -Wimplicit -Wreturn-type
> -Wdeclaration-after-statement -Wno-unknown-pragmas -Wmissing-prototypes
> -Wmissing-declarations -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith
> -Wcast-qual -Wcast-align -Wwrite-strings -Wold-style-definition
> test-053.c -o test-053
> test-053.c: In function ‘main’:
> test-053.c:4:12: warning: initialization discards ‘const’ qualifier from
> pointer target type [-Wdiscarded-qualifiers]
> char *a ="";
>
> hm.
>
In C nothing is really const, but fair enough. Maybe the attached patch
is better.
diff --git a/source/texk/web2c/luatexdir/lua/luastuff.c b/source/texk/web2c/luatexdir/lua/luastuff.c
index 0d9342223..1ce0f3198 100644
--- a/source/texk/web2c/luatexdir/lua/luastuff.c
+++ b/source/texk/web2c/luatexdir/lua/luastuff.c
@@ -665,14 +665,15 @@ void luatokencall(int p, int nameptr)
lua_State *luatex_error(lua_State * L, int is_fatal)
{
const_lstring luaerr;
- char *err = NULL;
+ const char *err = "";
if (lua_type(L, -1) == LUA_TSTRING) {
luaerr.s = lua_tolstring(L, -1, &luaerr.l);
/*tex
Free the last one.
*/
- err = (char *) xmalloc((unsigned) (luaerr.l + 1));
- snprintf(err, (luaerr.l + 1), "%s", luaerr.s);
+ char * nerr = (char *) xmalloc((unsigned) (luaerr.l + 1));
+ snprintf(nerr, (luaerr.l + 1), "%s", luaerr.s);
+ err = nerr;
/*tex
What if we have several .. not freed?
*/