From d2b2d36fcf5593a794bd158f1a853120cb50b8e0 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 20 May 2013 17:31:33 -0700 Subject: [PATCH] lazy allocation of HeadData in getBroadcastData --- libraries/avatars/src/AvatarData.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index fb97052151..5aaae9f3ad 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -68,6 +68,11 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) { // that can pack any type given the number of bytes // and return the number of bytes to push the pointer + // lazily allocate memory for HeadData in case we're not an Avatar instance + if (!_headData) { + _headData = new HeadData(); + } + // Body world position memcpy(destinationBuffer, &_position, sizeof(float) * 3); destinationBuffer += sizeof(float) * 3;