SVACE issue fix
[platform/core/messaging/msg-service.git] / plugin / sms_plugin / 3gpp2 / Sms3gpp2Codec.cpp
index 5a92d5b..c00684c 100755 (executable)
@@ -2074,9 +2074,6 @@ int Sms3gpp2MsgCodec::encodeUserData(const unsigned char* src, unsigned char *de
        int shift = 0;
 
        unsigned char *tmp = (unsigned char *)calloc(1, src_size+1);
-       for (i = 0; i < src_size; i++) {
-               tmp[i] = src[i] << 1;
-       }
 
        if (tmp == NULL){
                MSG_ERR("failed to allocate memory");
@@ -2084,6 +2081,10 @@ int Sms3gpp2MsgCodec::encodeUserData(const unsigned char* src, unsigned char *de
        }
 
        for (i = 0; i < src_size; i++) {
+               tmp[i] = src[i] << 1;
+       }
+
+       for (i = 0; i < src_size; i++) {
                shift = j % 7;
                dest[j++] = (tmp[i] << shift) + (tmp[i+1] >> (7-shift));
                if (shift == 6) {