Skip to content

Commit 116977a

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] [Hacker Rank] Warmup: Time Conversion solved ✅. Triying to fix sonarlint detected issues.
1 parent 45d9c42 commit 116977a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/exercises/src/hackerrank/warmup/time_conversion.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ char *HACKERRANK_WARMUP_timeConversion(const char *s) {
5151

5252
char time_str[TIME_SIZE];
5353
strcpy(time_str, s);
54-
const char *temp_time_str;
54+
char *temp_time_str;
5555
unsigned long time_str_len = strlen(time_str);
5656
temp_time_str = HACKERRANK_WARMUP_getLast(time_str, time_str_len - 2);
5757
strcpy(time_str, temp_time_str);
58+
free(temp_time_str);
5859
temp_time_str = HACKERRANK_WARMUP_getFirst(time_str, time_str_len - 2);
5960
strcpy(time_str, temp_time_str);
61+
free(temp_time_str);
6062

6163
char *endptr;
6264
long hour = strtol(hour_str, &endptr, 10);

0 commit comments

Comments
 (0)