[OpenSIPS-Devel] [OpenSIPS/opensips] d53e6f: json: fix array element deletion

Răzvan Crainea noreply at github.com
Mon Nov 13 05:57:42 UTC 2023


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: d53e6f32e7917e66b689c88ab0a660ea3e6e2d8f
      https://github.com/OpenSIPS/opensips/commit/d53e6f32e7917e66b689c88ab0a660ea3e6e2d8f
  Author: Bence Szigeti <bence.szigeti at gohyda.com>
  Date:   2023-11-10 (Fri, 10 Nov 2023)

  Changed paths:
    M modules/json/array_del.c

  Log Message:
  -----------
  json: fix array element deletion

OpenSIPS incorrectly calls the JSON-C array element deletion function by passing the size of the array instead of the desired count of elements to delete. When attempting to delete from index `0`, it results in the deletion of all elements, while specifying an index greater than `0` leads to no deletion due to overindexing.

### Example 1:
```
  $json(obj) := "[ 1, 2, 3 ]";
  $json(obj[0]) = NULL;
  xlog("$json(obj)\n");
```
Result:   `[]`
Expected: `[ 2, 3 ]`

### Example 2:
```
  $json(obj) := "[ 1, 2, 3 ]";
  $json(obj[1]) = NULL;
  xlog("$json(obj)\n");
```
Result:   `[ 1, 2, 3 ]`
Expected: `[ 1, 3 ]`


  Commit: 6ec8840f0e67520b05db0427fd05ead845ae3871
      https://github.com/OpenSIPS/opensips/commit/6ec8840f0e67520b05db0427fd05ead845ae3871
  Author: Răzvan Crainea <razvan at opensips.org>
  Date:   2023-11-13 (Mon, 13 Nov 2023)

  Changed paths:
    M modules/json/array_del.c

  Log Message:
  -----------
  Merge pull request #3243 from purecloudlabs/hotfix/json-array-del-element

json: fix array element deletion


Compare: https://github.com/OpenSIPS/opensips/compare/5cb0df80e79e...6ec8840f0e67



More information about the Devel mailing list