[tor-commits] [trunnel/master] It is not an error to set an array with allocated size 0 to have length 0.
nickm at torproject.org
nickm at torproject.org
Mon Jul 11 20:28:19 UTC 2016
commit 72da63f33808813869bfd7a99851da4307f34efb
Author: Nick Mathewson <nickm at torproject.org>
Date: Mon Jul 11 16:26:18 2016 -0400
It is not an error to set an array with allocated size 0 to have length 0.
---
lib/trunnel/CodeGen.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/trunnel/CodeGen.py b/lib/trunnel/CodeGen.py
index 16047b3..69ba2e3 100644
--- a/lib/trunnel/CodeGen.py
+++ b/lib/trunnel/CodeGen.py
@@ -1488,7 +1488,7 @@ class AccessorFnGenerator(CodeGenerator):
&inp->{c_name}.n_, inp->{c_name}.elts_, newlen,
sizeof(inp->{c_name}.elts_[0]), {freefn},
&inp->trunnel_error_code_);
- if (newptr == NULL)
+ if (newlen != 0 && newptr == NULL)
goto trunnel_alloc_failed;
inp->{c_name}.elts_ = newptr;
return 0;""", c_name=sva.c_name, freefn=freefn)
More information about the tor-commits
mailing list