Fix GEOSEARCH BYPOLYGON leak on invalid COUNT#3568
Conversation
Signed-off-by: Su Ko <rhtn1128@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #3568 +/- ##
============================================
- Coverage 76.42% 76.40% -0.02%
============================================
Files 159 159
Lines 80113 80128 +15
============================================
- Hits 61225 61221 -4
- Misses 18888 18907 +19
🚀 New features to boost your workflow:
|
Signed-off-by: Su Ko <rhtn1128@gmail.com>
enjoy-binbin
left a comment
There was a problem hiding this comment.
I don't know the details very well, however, the code structure makes it genuinely difficult to spot this issue. The most effective solution I can think of would likely be to add geoPolygonPointsFree to every error path. @KarthikSubbarao @bandalgomsu WDYT?
Also, we should perhaps standardize the usage of geoPolygonPointsFree here, rather than directly calling zfree(shape.t.polygon.points).
/* Extract polygon vertices. */
shape.conversion = 1;
shape.t.polygon.num_vertices = num_vertices;
shape.t.polygon.points = zmalloc(num_vertices * sizeof(double[2]));
for (int j = 0; j < num_vertices * 2; j += 2) {
if (extractLongLatOrReply(c, c->argv + base_args + i + 2 + j, shape.t.polygon.points[j / 2]) == C_ERR) {
zfree(shape.t.polygon.points);
return;
}
}
shape.type = POLYGON_TYPE;
|
I think adding
Make sense 👍 |
Signed-off-by: Su Ko <rhtn1128@gmail.com>
Free BYPOLYGON points before returning from invalid COUNT parsing paths in GEOSEARCH/GEOSEARCHSTORE. Closes valkey-io#3567 --------- Signed-off-by: Su Ko <rhtn1128@gmail.com> Co-authored-by: Binbin <binloveplay1314@qq.com>
Free BYPOLYGON points before returning from invalid COUNT parsing paths in GEOSEARCH/GEOSEARCHSTORE. Closes #3567 --------- Signed-off-by: Su Ko <rhtn1128@gmail.com> Co-authored-by: Binbin <binloveplay1314@qq.com>
Free BYPOLYGON points before returning from invalid COUNT parsing paths in GEOSEARCH/GEOSEARCHSTORE. Closes #3567 --------- Signed-off-by: Su Ko <rhtn1128@gmail.com> Co-authored-by: Binbin <binloveplay1314@qq.com>
Free BYPOLYGON points before returning from invalid COUNT parsing paths in GEOSEARCH/GEOSEARCHSTORE. Closes #3567 --------- Signed-off-by: Su Ko <rhtn1128@gmail.com> Co-authored-by: Binbin <binloveplay1314@qq.com>
Free BYPOLYGON points before returning from invalid COUNT parsing paths in GEOSEARCH/GEOSEARCHSTORE. Closes #3567 --------- Signed-off-by: Su Ko <rhtn1128@gmail.com> Co-authored-by: Binbin <binloveplay1314@qq.com>
Free BYPOLYGON points before returning from invalid COUNT parsing paths in GEOSEARCH/GEOSEARCHSTORE.
Closes #3567