Use delete[] to delete buffers allocated via new[]
authorDavin McCall <davmac@davmac.org>
Thu, 14 Jan 2016 10:02:40 +0000 (10:02 +0000)
committerDavin McCall <davmac@davmac.org>
Thu, 14 Jan 2016 10:02:40 +0000 (10:02 +0000)
(thank you LLVM static analyzer...)

src/dinitctl.cc

index 742b2de0acce87536656061a1bd119cae1088d9f..8a7f111e53b9bad2c73676cd8ec6cf1ac8232d53 100644 (file)
@@ -293,7 +293,7 @@ int main(int argc, char **argv)
             buf[1] = do_pin ? 1 : 0;
             memcpy(buf + 2, &handle, sizeof(handle));
             r = write_all(socknum, buf, 2 + sizeof(handle));
-            delete buf;
+            delete [] buf;
             
             if (r == -1) {
                 perror("write");
@@ -458,7 +458,7 @@ static int unpinService(int socknum, const char *service_name)
             buf[0] = DINIT_CP_UNPINSERVICE;
             memcpy(buf + 1, &handle, sizeof(handle));
             r = write_all(socknum, buf, 2 + sizeof(handle));
-            delete buf;
+            delete [] buf;
             
             if (r == -1) {
                 perror("write");