Skip to content

Commit

Permalink
Fix storing of lan log segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
airween committed Sep 28, 2024
1 parent 0e8b180 commit 7468def
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/log_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ struct qso_t *parse_qso(char *buffer) {

ptr = g_malloc0(sizeof(struct qso_t));

gchar *tbuffer = g_strdup(buffer);

/* remember whole line */
ptr->logline = g_strdup(buffer);
ptr->qsots = 0;
Expand All @@ -103,7 +105,7 @@ struct qso_t *parse_qso(char *buffer) {

/* split buffer into parts for linedata_t record and parse
* them accordingly */
tmp = strtok_r(buffer, " \t", &sp);
tmp = strtok_r(tbuffer, " \t", &sp);

/* band */
ptr->band = atoi(tmp);
Expand Down Expand Up @@ -144,17 +146,21 @@ struct qso_t *parse_qso(char *buffer) {
ptr->rst_r = atoi(strtok_r(NULL, " \t", &sp));

/* comment (exchange) */
ptr->comment = g_strndup(buffer + 54, contest->exchange_width);
ptr->comment = g_strndup(tbuffer + 54, contest->exchange_width);

/* tx */
ptr->tx = (buffer[79] == '*') ? 1 : 0;
ptr->tx = (tbuffer[79] == '*') ? 1 : 0;

/* frequency (kHz) */
ptr->freq = atof(buffer + 80) * 1000.0;
ptr->freq = atof(tbuffer + 80) * 1000.0;
if (freq2bandindex(ptr->freq) == BANDINDEX_OOB) {
ptr->freq = 0.;
}

if (tbuffer != NULL) {
g_free(tbuffer);
}

return ptr;
}

Expand Down

0 comments on commit 7468def

Please sign in to comment.