[Asterisk-code-review] vector: Prevent NULL argument to memcpy. (asterisk[13])
Corey Farrell
asteriskteam at digium.com
Sun Oct 30 13:44:06 CDT 2016
Corey Farrell has uploaded a new change for review. ( https://gerrit.asterisk.org/4234 )
Change subject: vector: Prevent NULL argument to memcpy.
......................................................................
vector: Prevent NULL argument to memcpy.
Headers declare that memcpy does not accept NULL argument for the first
two parameters. Add a conditional block to prevent memcpy and ast_free
from running on vectors with NULL element array.
ASTERISK-26526 #close
Change-Id: I988a476bb5fcfcbd3f6d6c6b3e7769e4f9629b71
---
M include/asterisk/vector.h
1 file changed, 5 insertions(+), 3 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/34/4234/1
diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h
index 4306670..6b4e632 100644
--- a/include/asterisk/vector.h
+++ b/include/asterisk/vector.h
@@ -172,9 +172,11 @@
typeof((vec)->elems) new_elems = ast_calloc(1, \
new_max * sizeof(*new_elems)); \
if (new_elems) { \
- memcpy(new_elems, (vec)->elems, \
- (vec)->current * sizeof(*new_elems)); \
- ast_free((vec)->elems); \
+ if ((vec)->elems) { \
+ memcpy(new_elems, (vec)->elems, \
+ (vec)->current * sizeof(*new_elems)); \
+ ast_free((vec)->elems); \
+ } \
(vec)->elems = new_elems; \
(vec)->max = new_max; \
} else { \
--
To view, visit https://gerrit.asterisk.org/4234
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I988a476bb5fcfcbd3f6d6c6b3e7769e4f9629b71
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Corey Farrell <git at cfware.com>
More information about the asterisk-code-review
mailing list