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) {
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[0]=nodes+1;
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;
size_t written=0,i;
char c;
unsigned int prev,cur,todo;
prev=cur=(unsigned int)-1;
unsigned int prev,todo;
prev=(unsigned int)-1;
for (i=0; s[i]; ++i) {
if (s[i]=='"') {
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':
{
size_t j;
unsigned int cur;
for (cur=j=0; j<4; ++j) {
char x=scan_fromhex(s[i+2+j]);
if (x<0) goto abort; // not hex -> invalid input

Loading…
Cancel
Save