Skip to content

Commit

Permalink
Only check the pointer if the length is greater than zero, and ensure…
Browse files Browse the repository at this point in the history
… that the

pointer is only examined if the length if greater than zero.
  • Loading branch information
anthony-tuininga committed Nov 22, 2019
1 parent ad75cae commit 7693865
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dpiVar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,8 @@ static int dpiVar__setFromBytes(dpiVar *var, uint32_t pos, const char *value,
dynBytes = &var->buffer.dynamicBytes[pos];
if (dpiVar__allocateDynamicBytes(dynBytes, valueLength, error) < 0)
return DPI_FAILURE;
memcpy(dynBytes->chunks->ptr, value, valueLength);
if (valueLength > 0)
memcpy(dynBytes->chunks->ptr, value, valueLength);
dynBytes->numChunks = 1;
dynBytes->chunks->length = valueLength;
bytes->ptr = dynBytes->chunks->ptr;
Expand Down Expand Up @@ -1687,7 +1688,7 @@ int dpiVar_setFromBytes(dpiVar *var, uint32_t pos, const char *value,

if (dpiVar__checkArraySize(var, pos, __func__, &error) < 0)
return dpiGen__endPublicFn(var, DPI_FAILURE, &error);
DPI_CHECK_PTR_NOT_NULL(var, value)
DPI_CHECK_PTR_AND_LENGTH(var, value)
if (var->nativeTypeNum != DPI_NATIVE_TYPE_BYTES &&
var->nativeTypeNum != DPI_NATIVE_TYPE_LOB) {
dpiError__set(&error, "native type", DPI_ERR_NOT_SUPPORTED);
Expand Down

0 comments on commit 7693865

Please sign in to comment.