Skip to content

Commit

Permalink
Fixed ‘length’ may be used uninitialized in Array.prototype.pop().
Browse files Browse the repository at this point in the history
When building by GCC with -O3 and -flto flags the following
warning was reported:
src/njs_array.c: In function ‘njs_array_prototype_pop’:
src/njs_array.c:1009:8: error: ‘length’ may be used uninitialized in
this function [-Werror=maybe-uninitialized]
1009 | if (length == 0) {
     |     ^

Returning a specific code in njs_value_to_number() helps GCC
to infer that there are only 2 return values are possible and
both of them are handled.
  • Loading branch information
xeioex committed Jun 29, 2024
1 parent a14be61 commit 1c2c7af
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/njs_value_conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ njs_value_to_number(njs_vm_t *vm, njs_value_t *value, double *dst)
if (njs_slow_path(!njs_is_primitive(value))) {
ret = njs_value_to_primitive(vm, &primitive, value, 0);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
return NJS_ERROR;
}

value = &primitive;
Expand Down

0 comments on commit 1c2c7af

Please sign in to comment.