After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 708318 - json_path_compile() crashes on NULL expression
json_path_compile() crashes on NULL expression
Status: RESOLVED FIXED
Product: json-glib
Classification: Core
Component: Parser
git master
Other Linux
: Normal normal
: ---
Assigned To: json-glib-maint
json-glib-maint
Depends on:
Blocks:
 
 
Reported: 2013-09-18 17:51 UTC by Juan A. Suarez Romero
Modified: 2013-09-19 08:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
path: Check if JSONPath expression is NULL (853 bytes, patch)
2013-09-18 17:53 UTC, Juan A. Suarez Romero
needs-work Details | Review
path: Check if JSONPath expression is NULL (699 bytes, patch)
2013-09-18 22:44 UTC, Juan A. Suarez Romero
committed Details | Review

Description Juan A. Suarez Romero 2013-09-18 17:51:02 UTC
When passing a NULL expresssion, json_path_compile() crashes, because it is not checking if expression can be NULL.
Comment 1 Juan A. Suarez Romero 2013-09-18 17:53:28 UTC
Created attachment 255238 [details] [review]
path: Check if JSONPath expression is NULL
Comment 2 Emmanuele Bassi (:ebassi) 2013-09-18 21:59:55 UTC
Review of attachment 255238 [details] [review]:

::: json-glib/json-path.c
@@ +423,3 @@
 
+  if (p == NULL) {
+    g_set_error_literal (error, JSON_PATH_ERROR,

coding style: braces go on a new line and indentation level.

I also don't think this is a recoverable error: we should just return if the string is NULL. the empty string "" is a valid path.
Comment 3 Juan A. Suarez Romero 2013-09-18 22:44:16 UTC
Created attachment 255261 [details] [review]
path: Check if JSONPath expression is NULL
Comment 4 Emmanuele Bassi (:ebassi) 2013-09-18 22:48:19 UTC
Review of attachment 255261 [details] [review]:

looks good. feel free to commit to both master and json-glib-0-16 branches.
Comment 5 Juan A. Suarez Romero 2013-09-19 08:27:07 UTC
Attachment 255261 [details] pushed as ce46c06 - path: Check if JSONPath expression is NULL