fix two complaints by clang's static analyzer

master
leitner 4 years ago
parent 69c9d1454d
commit 19c65ab54f

@ -128,8 +128,12 @@ void marshalhelper(struct letters* s) {
void marshal(struct letters* s) { void marshal(struct letters* s) {
fprintf(stderr,"nodes=%zu, datasize=%zu\n",nodes,datasize); fprintf(stderr,"nodes=%zu, datasize=%zu\n",nodes,datasize);
heap=malloc((nodes+1)*sizeof(uint32_t)+datasize); {
if (!heap) nomem(); size_t l;
heap=malloc(l=(nodes+1)*sizeof(uint32_t)+datasize);
if (!heap) nomem();
memset(heap,0,l);
}
marshaled=(uint32_t*)heap; marshaled=(uint32_t*)heap;
marshaled[0]=nodes+1; marshaled[0]=nodes+1;
data=heap+(nodes+1)*sizeof(uint32_t); data=heap+(nodes+1)*sizeof(uint32_t);

@ -6,8 +6,8 @@ size_t scan_jsonescape(const char *src,char *dest,size_t *destlen) {
register const unsigned char* s=(const unsigned char*) src; register const unsigned char* s=(const unsigned char*) src;
size_t written=0,i; size_t written=0,i;
char c; char c;
unsigned int prev,cur,todo; unsigned int prev,todo;
prev=cur=(unsigned int)-1; prev=(unsigned int)-1;
for (i=0; s[i]; ++i) { for (i=0; s[i]; ++i) {
if (s[i]=='"') { if (s[i]=='"') {
if (prev!=(unsigned int)-1) goto abort; if (prev!=(unsigned int)-1) goto abort;
@ -27,6 +27,7 @@ size_t scan_jsonescape(const char *src,char *dest,size_t *destlen) {
case 'u': case 'u':
{ {
size_t j; size_t j;
unsigned int cur;
for (cur=j=0; j<4; ++j) { for (cur=j=0; j<4; ++j) {
char x=scan_fromhex(s[i+2+j]); char x=scan_fromhex(s[i+2+j]);
if (x<0) goto abort; // not hex -> invalid input if (x<0) goto abort; // not hex -> invalid input

Loading…
Cancel
Save