safeguard
authorVolker Birk <vb@pep-project.org>
Thu, 01 Dec 2016 17:12:54 +0100
changeset 224b0290a75f7a5
parent 223 490e6399476b
child 225 9db6ab24dee7
safeguard
pEp_utility.cpp
     1.1 --- a/pEp_utility.cpp	Thu Dec 01 16:44:03 2016 +0100
     1.2 +++ b/pEp_utility.cpp	Thu Dec 01 17:12:54 2016 +0100
     1.3 @@ -400,7 +400,7 @@
     1.4  
     1.5                  char *buffer;
     1.6                  if (size) {
     1.7 -                    buffer = (char *) calloc(1, size);
     1.8 +                    buffer = (char *) malloc(size + 1);
     1.9                      if (buffer == NULL)
    1.10                          throw bad_alloc();
    1.11  
    1.12 @@ -408,6 +408,7 @@
    1.13  
    1.14                      SafeArrayAccessData(b.value, (void **) &data);
    1.15                      memcpy(buffer, data, size);
    1.16 +					buffer[size] = 0; // safeguard
    1.17                      SafeArrayUnaccessData(sa);
    1.18                  }
    1.19                  else {