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 692101 - g_data_input_stream_read_upto_async returns NULL when it should return ""
g_data_input_stream_read_upto_async returns NULL when it should return ""
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-01-19 20:51 UTC by Shaun McCance
Modified: 2018-05-24 14:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test program showing the difference between sync and async variants (1.71 KB, text/x-csrc)
2013-01-19 20:54 UTC, Shaun McCance
  Details
Proposed fix (1.98 KB, patch)
2013-01-20 02:27 UTC, Shaun McCance
none Details | Review
Simpler, better fix (1.80 KB, patch)
2013-01-20 02:51 UTC, Shaun McCance
needs-work Details | Review

Description Shaun McCance 2013-01-19 20:51:53 UTC
If the next character in the stream is one of the stop chars, g_data_input_stream_read_upto_finish will return NULL, seemingly with no way to distinguish this from hitting the end of the stream. In contract, g_data_input_stream_read_upto will return "" in the exact same case, which is what I would expect. Attaching a test program.
Comment 1 Shaun McCance 2013-01-19 20:54:02 UTC
Created attachment 233898 [details]
Test program showing the difference between sync and async variants

Compile with gcc -o testupto `pkg-config --cflags --libs gio-2.0` testupto.c
Comment 2 Shaun McCance 2013-01-20 02:27:18 UTC
Created attachment 233927 [details] [review]
Proposed fix
Comment 3 Shaun McCance 2013-01-20 02:46:45 UTC
In retrospect, a gboolean would have made more sense.
Comment 4 Shaun McCance 2013-01-20 02:51:31 UTC
Created attachment 233928 [details] [review]
Simpler, better fix
Comment 5 Dan Winship 2013-01-21 16:12:27 UTC
Comment on attachment 233928 [details] [review]
Simpler, better fix

hm... I think a "gboolean eof" (with the opposite value from "allow_empty") would be clearer.

also, adding a test to gio/tests/data-input-stream.c would be great...
Comment 6 Philip Withnall 2018-02-16 11:31:44 UTC
Review of attachment 233928 [details] [review]:

Yeah, this looks good. Can you please include a test case in gio/tests/data-input-stream.c though?
Comment 7 GNOME Infrastructure Team 2018-05-24 14:56:51 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/655.