Skip to content

Commit

Permalink
Fixes for issues spotted by infer
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Nov 29, 2024
1 parent 51e820d commit 83c4867
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
README-orig.md
README-xchange.md
TODO
infer-out
4 changes: 2 additions & 2 deletions src/xjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ static char *SkipSpaces(char *str, int *lineNumber) {
}

static char *GetToken(char *from) {
int l;
int l = 0;
char *token;

from = SkipSpaces(from, &l);
Expand Down Expand Up @@ -684,7 +684,7 @@ static void *ParseArray(char **pos, XType *type, int *ndim, int sizes[X_MAX_DIMS
return NULL;
}

next = SkipSpaces(++next, lineNumber);
next = SkipSpaces(next+1, lineNumber);

for(n = 0; *next && *next != ']';) {
XField *e;
Expand Down
6 changes: 6 additions & 0 deletions src/xlookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ static int xLookupPutAllAsync(XLookupTable *tab, const char *prefix, const XStru
if(f->type == X_STRUCT && recursive) {
XStructure *sub = (XStructure *) f->value;
char *p1 = (char *) malloc(lp + strlen(f->value) + 2 * sizeof(X_SEP) + 12);
x_check_alloc(p1);

int count = xGetFieldCount(f);
while(--count >= 0) {
Expand All @@ -205,6 +206,8 @@ static int xLookupPutAllAsync(XLookupTable *tab, const char *prefix, const XStru

N += xLookupPutAllAsync(tab, p1, &sub[count], TRUE);
}

free(p1);
}
}

Expand All @@ -225,6 +228,7 @@ static int xLookupRemoveAllAsync(XLookupTable *tab, const char *prefix, const XS
if(f->type == X_STRUCT && recursive) {
XStructure *sub = (XStructure *) f->value;
char *p1 = (char *) malloc(lp + strlen(f->value) + 2 * sizeof(X_SEP) + 12);
x_check_alloc(p1);

int count = xGetFieldCount(f);
while(--count >= 0) {
Expand All @@ -236,6 +240,8 @@ static int xLookupRemoveAllAsync(XLookupTable *tab, const char *prefix, const XS

N += xLookupRemoveAllAsync(tab, p1, &sub[count], TRUE);
}

free(p1);
}
}

Expand Down

0 comments on commit 83c4867

Please sign in to comment.