diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp
index 2001359e503b787f591814b740fff1ebef742fa9..c667b0af3f75f39396ca0a0051d551681c044f4a 100644
--- a/indra/newview/llmachineid.cpp
+++ b/indra/newview/llmachineid.cpp
@@ -224,11 +224,11 @@ S32 LLMachineID::init()
             unsigned int serial_size = SysStringLen(serialNumber);
             unsigned int j = 0;
 
-            while (j < serial_size)
+            while (j < serial_size && vtProp.bstrVal[j] != 0)
             {
                 for (unsigned int i = 0; i < len; i++)
                 {
-                    if (j >= serial_size)
+                    if (j >= serial_size || vtProp.bstrVal[j] == 0)
                         break;
 
                     static_unique_id[i] = (unsigned int)(static_unique_id[i] + serialNumber[j]);