Skip to content

Commit 6e413f6

Browse files
committed
Fix memory issue
1 parent aa31ff6 commit 6e413f6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libasr/runtime/lfortran_intrinsics.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,7 @@ LFORTRAN_API char* _lfortran_str_slice_assign(char* s, char *r, int32_t idx1, in
23042304
return s;
23052305
}
23062306

2307-
char* dest_char = (char*)malloc(s_len);
2307+
char* dest_char = (char*)malloc(s_len + 1);
23082308
strcpy(dest_char, s);
23092309
int s_i = idx1, d_i = 0;
23102310
while((step > 0 && s_i >= idx1 && s_i < idx2) ||
@@ -3367,7 +3367,7 @@ uint32_t get_file_size(int64_t fp) {
33673367
void get_local_info_dwarfdump(struct Stacktrace *d) {
33683368
// TODO: Read the contents of lines.dat from here itself.
33693369
char *base_name = get_base_name(source_filename);
3370-
char *filename = malloc(strlen(base_name) + 14);
3370+
char *filename = malloc(strlen(base_name) + 15);
33713371
strcpy(filename, base_name);
33723372
strcat(filename, "_lines.dat.txt");
33733373
int64_t fd = _lpython_open(filename, "r");

0 commit comments

Comments
 (0)