mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Fixing two memory leaks.
This commit is contained in:
parent
36dbaa5b92
commit
2252e9d90b
1 changed files with 10 additions and 6 deletions
|
@ -482,8 +482,8 @@ function to_lower%(str: string%): string
|
||||||
%{
|
%{
|
||||||
const u_char* s = str->Bytes();
|
const u_char* s = str->Bytes();
|
||||||
int n = str->Len();
|
int n = str->Len();
|
||||||
char* lower_s = new char[n];
|
u_char* lower_s = new u_char[n + 1];
|
||||||
char* ls = lower_s;
|
u_char* ls = lower_s;
|
||||||
|
|
||||||
for ( int i = 0; i < n; ++i)
|
for ( int i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
|
@ -493,15 +493,17 @@ function to_lower%(str: string%): string
|
||||||
*ls++ = s[i];
|
*ls++ = s[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StringVal(n, lower_s);
|
*ls++ = '\0';
|
||||||
|
|
||||||
|
return new StringVal(new BroString(1, lower_s, n));
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function to_upper%(str: string%): string
|
function to_upper%(str: string%): string
|
||||||
%{
|
%{
|
||||||
const u_char* s = str->Bytes();
|
const u_char* s = str->Bytes();
|
||||||
int n = str->Len();
|
int n = str->Len();
|
||||||
char* upper_s = new char[n];
|
u_char* upper_s = new u_char[n + 1];
|
||||||
char* us = upper_s;
|
u_char* us = upper_s;
|
||||||
|
|
||||||
for ( int i = 0; i < n; ++i)
|
for ( int i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
|
@ -511,7 +513,9 @@ function to_upper%(str: string%): string
|
||||||
*us++ = s[i];
|
*us++ = s[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StringVal(n, upper_s);
|
*us++ = '\0';
|
||||||
|
|
||||||
|
return new StringVal(new BroString(1, upper_s, n));
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function clean%(str: string%): string
|
function clean%(str: string%): string
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue