Fix an undefined behaviour and a memory leak (#289)

* Use a unique_ptr to avoid leaks

* Use memmove instead of memcopy

As both arguments can overlap, use memmove instead of memcopy

* Fix code style issues
This commit is contained in:
Waylander 2025-09-04 00:12:26 +02:00 committed by GitHub
parent e4a1ebf00e
commit 849832a951
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -2963,6 +2963,7 @@ Sta::netSlack(const Net *net,
slack = pin_slack;
}
}
delete pin_iter;
return slack;
}

View File

@ -117,7 +117,7 @@ public:
int n_putback = gptr() - eback();
if ( n_putback > 4)
n_putback = 4;
memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback);
memmove( buffer + (4 - n_putback), gptr() - n_putback, n_putback);
int num = gzread( file, buffer+4, bufferSize-4);
if (num <= 0) // ERROR or EOF