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

Re: [PATCH 3/3] Constify two local variables.



On Nov 30,  3:59pm, Daniel Shahaf wrote:
}
} I'm asking because I found that $region_highlights' getfn returns
} a heap-allocated array, while its setfn calls free() on the array passed
} to it, so
} .
}     Param pm = $region_highlights;
}     values_a = pm->gsu.a->getfn();
}     pm->gsu.a->setfn(values_a);
} .
} is undefined behaviour (calls free() on a heap pointer, triggering SIGABRT).

In general you can't pass the result of any getfn() back to its own
or anyone else's setfn().  All setfn() should always expect a newly-
zshcalloc()d [or the equivalent] array.



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