diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp
index df177adb7b28fc1128e4b3ecafd915d4f4c8a686..de4ac848ca30dbdbe62d8cd0fd11fb1e14d2a33f 100644
--- a/indra/newview/llviewerjoystick.cpp
+++ b/indra/newview/llviewerjoystick.cpp
@@ -475,7 +475,10 @@ void LLViewerJoystick::initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8
 #if LIB_NDOF
     mLastDeviceUUID = guid;
 
-    strncpy(mNdofDev->product, name.c_str(), sizeof(mNdofDev->product));
+    size_t dest_size = sizeof(mNdofDev->product);
+    strncpy(mNdofDev->product, name.c_str(), dest_size-1);
+    mNdofDev->product[dest_size] = '\0';
+    
     mNdofDev->manufacturer[0] = '\0';
 
     initDevice(preffered_device);