Skip to content

Commit 773024a

Browse files
author
Ward Fisher
committed
Addressed Coverity issue 711896
1 parent 2cce056 commit 773024a

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

ncgen/bytebuffer.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ bbNew(void)
4141
bb->length=0;
4242
bb->content=NULL;
4343
bb->nonextendible = 0;
44-
return bb;
44+
return bb;
4545
}
4646

4747
int
@@ -87,7 +87,7 @@ bbFill(Bytebuffer* bb, const char fill)
8787
{
8888
unsigned int i;
8989
if(bb == NULL) return bbFail();
90-
for(i=0;i<bb->length;i++) bb->content[i] = fill;
90+
for(i=0;i<bb->length;i++) bb->content[i] = fill;
9191
return TRUE;
9292
}
9393

@@ -166,13 +166,16 @@ bbInsertn(Bytebuffer* bb, const unsigned int index, const char* elem, const unsi
166166
{
167167
unsigned int i;
168168
int j;
169-
unsigned int newlen = bb->length + n;
169+
unsigned int newlen = 0;
170170

171171
if(bb == NULL) return bbFail();
172+
173+
newlen = bb->length + n;
174+
172175
if(newlen >= bb->alloc) {
173176
if(!bbExtend(bb,n)) return bbFail();
174177
}
175-
/*
178+
/*
176179
index=0
177180
n=3
178181
len=3
@@ -202,8 +205,8 @@ bbHeadpop(Bytebuffer* bb, char* pelem)
202205
*pelem = bb->content[0];
203206
memcpy((void*)&bb->content[0],(void*)&bb->content[1],
204207
sizeof(char)*(bb->length - 1));
205-
bb->length--;
206-
return TRUE;
208+
bb->length--;
209+
return TRUE;
207210
}
208211

209212
int
@@ -212,8 +215,8 @@ bbTailpop(Bytebuffer* bb, char* pelem)
212215
if(bb == NULL) return bbFail();
213216
if(bb->length == 0) return bbFail();
214217
*pelem = bb->content[bb->length-1];
215-
bb->length--;
216-
return TRUE;
218+
bb->length--;
219+
return TRUE;
217220
}
218221

219222
int
@@ -222,7 +225,7 @@ bbHeadpeek(Bytebuffer* bb, char* pelem)
222225
if(bb == NULL) return bbFail();
223226
if(bb->length == 0) return bbFail();
224227
*pelem = bb->content[0];
225-
return TRUE;
228+
return TRUE;
226229
}
227230

228231
int
@@ -231,7 +234,7 @@ bbTailpeek(Bytebuffer* bb, char* pelem)
231234
if(bb == NULL) return bbFail();
232235
if(bb->length == 0) return bbFail();
233236
*pelem = bb->content[bb->length - 1];
234-
return TRUE;
237+
return TRUE;
235238
}
236239

237240
char*

0 commit comments

Comments
 (0)