Bug 96250 - Crash when passing empty string as pRenderingArguments in LOK view
Summary: Crash when passing empty string as pRenderingArguments in LOK view
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Linguistic (show other bugs)
Version:
(earliest affected)
5.1.0.0.beta1
Hardware: All All
: medium normal
Assignee: Miklos Vajna
URL:
Whiteboard: target:5.2.0 target:5.1.0.1 target:5...
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-04 18:20 UTC by Bastien Nocera
Modified: 2016-10-25 19:11 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bastien Nocera 2015-12-04 18:20:58 UTC
It's a very simple ODT file created with LibreOffice, and that I can open with the same version of LibreOffice [1].

$ cat test.js 
#!/usr/bin/gjs

const Gtk = imports.gi.Gtk;
const LOKDocView = imports.gi.LOKDocView;

function open_document_cb(res, doc) {
	print ("open document cb got called");
}

Gtk.init(null);

let view = LOKDocView.View.new("/usr/lib64/libreoffice/program/", null, null);
let location = "/home/hadess/Documents/Battery user testing.odt";
this.view.open_document(location, "", null, function() {
	print ("open document cb got called");
});

Gtk.main();


$ GI_TYPELIB_PATH=$GI_TYPELIB_PATH:/usr/lib64/libreoffice/girepository-1.0/ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/libreoffice/program/ gjs test.js 

open document cb got called
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::json_parser::json_parser_error> >'
  what():  <unspecified file>(1): expected value
Application Error

Make sure to change the path to the ODT file when testing it.

[1]: From here: http://koji.fedoraproject.org/koji/buildinfo?buildID=703072
Comment 1 Bastien Nocera 2015-12-04 19:23:10 UTC
The "fix" is:
-this.view.open_document(location, "", null, function() {
+this.view.open_document(location, "{}", null, function() {

The pRenderingArguments argument needs to be valid JSON. Still, it shouldn't crash, and consider either NULL, or "" as empty JSON.
Comment 2 Miklos Vajna 2015-12-05 21:47:11 UTC
NULL is already considered as empty JSON. "" is not, I'll fix that.
Comment 3 Commit Notification 2015-12-07 14:14:30 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5cc574fefc8a2ee39db4a4bd843a3ec67dce2f11

tdf#96250 desktop: empty str is the same as 0 str in jsonToPropertyValues()

It will be available in 5.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Commit Notification 2015-12-07 14:24:56 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-5-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e22f9ae034addbddbb5581cdee6bfd1c39aeedea&h=libreoffice-5-1

tdf#96250 desktop: empty str is the same as 0 str in jsonToPropertyValues()

It will be available in 5.1.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Debarshi Ray 2015-12-16 17:23:57 UTC
lok_doc_view_open_document still doesn't accept NULL as a valid value for pRenderingArguments, even if it is annotated as (nullable). The implementation needs a NULL check before:
  priv->m_aRenderingArguments = pRenderingArguments;
Comment 6 Commit Notification 2015-12-16 19:34:16 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=032e34d0014d2154feaf97105d2dbe69b290b8c5

tdf#96250 LOK: guard against 0 pRenderingArguments

It will be available in 5.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Miklos Vajna 2015-12-16 20:14:27 UTC
Works for me now, please speak up if it still does not. :-)
Comment 8 Commit Notification 2015-12-17 16:05:09 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-5-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e390b5f4f1267071245e452baa8dd63cdb556f1d&h=libreoffice-5-1

tdf#96250 LOK: guard against 0 pRenderingArguments

It will be available in 5.1.0.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.