Skip to content

Commit

Permalink
fixed bugs in json serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
justanhduc committed Mar 15, 2023
1 parent 2150872 commit 4df1dee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ static int add_job_to_json_array(struct Job *p, cJSON *jobs) {

void s_list(int s, enum ListFormat listFormat) {
struct Job *p;
char *buffer;
char *buffer = 0;

if (listFormat == DEFAULT) {
/* Times: 0.00/0.00/0.00 - 4+4+4+2 = 14*/
Expand Down Expand Up @@ -522,9 +522,11 @@ void s_list(int s, enum ListFormat listFormat) {
// append newline
size_t buffer_strlen = strlen(buffer);
buffer = realloc(buffer, buffer_strlen+1+1);
buffer[buffer_strlen] = '\n';
strcat(buffer, "\n");

send_list_line(s, buffer);
goto end;

end:
cJSON_Delete(jobs);
free(buffer);
Expand Down

0 comments on commit 4df1dee

Please sign in to comment.