Commit ab046b09 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixed some memory leaks and compiler warnings



Change-Id: I9297f78eabbf0217c3645032cf8e6c011d7fc206
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent ab538d44
......@@ -96,6 +96,7 @@ UnicharPattern::UnicharPattern() : mappings_head(NULL)
if (fp == NULL) {
TTCN_pattern_warning("Cannot open file '%s' for reading. "
"Case-insensitive universal charstring patterns are disabled.\n", mappings_file);
Free(mappings_file);
return;
}
Free(mappings_file);
......
......@@ -119,7 +119,7 @@ HEXDIGIT [0-9A-Fa-f]
Location loc(current_file, current_line, current_column, current_line,
current_column + yyleng);
loc.warning("Unknown escape sequence `%s' was treated literally", yytext);
for (size_t i = 0; i < yyleng; i++) ADD_CHAR(yytext[i]);
for (size_t i = 0; i < (size_t)yyleng; i++) ADD_CHAR(yytext[i]);
current_column += 2;
}
......@@ -133,7 +133,7 @@ HEXDIGIT [0-9A-Fa-f]
{NEWLINE} {
Location loc(current_file, current_line, current_column, current_line + 1, 0);
loc.warning("Unescaped newline character");
for (size_t i = 0; i < yyleng; i++) ADD_CHAR(yytext[i]);
for (size_t i = 0; i < (size_t)yyleng; i++) ADD_CHAR(yytext[i]);
current_line++;
current_column = 0;
}
......
......@@ -51,7 +51,7 @@ using namespace Common;
static void update_location(size_t start_index, size_t end_index,
size_t& current_line, size_t& current_column)
{
for (size_t i = start_index; i < yyleng && i < end_index; i++) {
for (size_t i = start_index; i < (size_t)yyleng && i < end_index; i++) {
// count CR, count LF, but count CR + LF as one
switch (yytext[i]) {
case '\r':
......
......@@ -184,7 +184,8 @@ omit RETURN(XOmitKeyword);
current_column += 2;
bool backslash_flag = false;
yylval.str = memptystr();
for (size_t i = 2; i < yyleng - 2; ) {
size_t len = (size_t)yyleng - 2;
for (size_t i = 2; i < len; ) {
if (!backslash_flag && (yytext[i] == '\\' || yytext[i] == '"') &&
yytext[i + 1] == '"' &&
(yytext[i + 2] == '\\' || yytext[i + 2] == '"') &&
......@@ -496,7 +497,8 @@ definite RETURN(XKWdefinite);
current_column++;
bool backslash_flag = false;
yylval.str = memptystr();
for (size_t i = 1; i < yyleng - 1; ) {
size_t len = (size_t)yyleng - 1;
for (size_t i = 1; i < len; ) {
if (!backslash_flag && (yytext[i] == '\'' || yytext[i] == '"') &&
yytext[i + 1] == yytext[i]) {
/* transform '' -> \' and "" -> \" */
......
......@@ -93,6 +93,7 @@ void TTCN3_Debugger::set_breakpoint(const char* p_module, const char* p_location
batch_file != NULL ? batch_file : "", batch_file != NULL ? "'" : "");
}
else {
Free(function);
if (breakpoints[pos].batch_file != NULL) {
if (batch_file != NULL) {
if (!strcmp(batch_file, breakpoints[pos].batch_file)) {
......
......@@ -66,15 +66,15 @@ size_t Module_Param_Id::get_nof_names() const {
char* Module_Param_Name::get_str() const {
char* result = NULL;
for (size_t i = 0; i < names.size(); ++i) {
boolean is_index = names[i][0] >= '0' && names[i][0] <= '9';
if (i > 0 && !is_index) {
boolean index = names[i][0] >= '0' && names[i][0] <= '9';
if (i > 0 && !index) {
result = mputc(result, '.');
}
if (is_index) {
if (index) {
result = mputc(result, '[');
}
result = mputstr(result, names[i]);
if (is_index) {
if (index) {
result = mputc(result, ']');
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment