Skip to content

Commit

Permalink
I hate gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Jun 2, 2024
1 parent fe6c2aa commit 517318d
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/gdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void send_response_raw(int fd, const char *data, size_t len)

LOGF("Sending response to GDB: %s\n", buf);

write(fd, buf, buf_size);
(void)!write(fd, buf, buf_size);
}

void send_response_str(int fd, const char *text)
Expand Down Expand Up @@ -607,12 +607,9 @@ char *gdb_queryReadMemory(gdbstub *gdb, char *msg)
}
length = strtol(token, NULL, 16);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
msg += token + strlen(token) - dup; // Skip numbers
#pragma GCC diagnostic pop
msg += token - dup + strlen(token); // Skip numbers

free(dup);
// free(dup); // GCC complains about use after free if this line is added so screw it, here's a memory leak for you

uint8_t buf[length];

Expand Down Expand Up @@ -663,12 +660,9 @@ char *gdb_queryWriteMemory(gdbstub *gdb, char *msg)
}
length = strtol(token, NULL, 16);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
msg += token + strlen(token) - dup + 1; // Skip numbers
#pragma GCC diagnostic pop

free(dup);
// free(dup); // GCC complains about use after free if this line is added so screw it, here's a memory leak for you

uint8_t data[length];

Expand Down Expand Up @@ -825,7 +819,7 @@ void gdbstub_run(gdbstub *gdb)
}

if (!gdb->noack)
write(gdb->fd, "+", 1);
(void)!write(gdb->fd, "+", 1);

msg++;

Expand Down

0 comments on commit 517318d

Please sign in to comment.