[PATCH] Avoid walking off array if given a negative value for array size.
José Fonseca
jose.r.fonseca at gmail.com
Mon Jun 11 08:56:37 PDT 2012
Thanks. I've commited this, with a small modification to preserve the
distinction between zero-length arrays, and NULL array pointers, which
makes a difference for certain function calls.
Jose
On Mon, Jun 4, 2012 at 10:47 PM, Carl Worth <cworth at cworth.org> wrote:
> Obviously, a negative size is bogus, but we want apitrace to be robust
> enough to capture even bogus usage of the API, (so that the user can
> investigate and fix the bogosity in the application).
>
> In this case, if the user specifies a negative size for an array,
> simply don't write anything out for the array content.
> ---
> wrappers/trace.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/wrappers/trace.py b/wrappers/trace.py
> index 659fcd9..533937c 100644
> --- a/wrappers/trace.py
> +++ b/wrappers/trace.py
> @@ -186,7 +186,7 @@ class ValueSerializer(stdapi.Visitor):
> def visitArray(self, array, instance):
> length = '_c' + array.type.tag
> index = '_i' + array.type.tag
> - print ' if (%s) {' % instance
> + print ' if (%s && %s > 0) {' % (instance, array.length)
> print ' size_t %s = %s;' % (length, array.length)
> print ' trace::localWriter.beginArray(%s);' % length
> print ' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index)
> --
> 1.7.10
>
> _______________________________________________
> apitrace mailing list
> apitrace at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/apitrace
More information about the apitrace
mailing list