Closed Bug 448266 Opened 16 years ago Closed 12 years ago

[@ gtk_moz_embed_render_data] crashes if a wrong Content-Type is given

Categories

(Core Graveyard :: Embedding: GTK Widget, defect)

x86
Linux
defect
Not set
critical

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: Keisial, Unassigned)

Details

(Keywords: crash)

Crash Data

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Build Identifier: 

gtk_moz_embed_render_data crashes if given a Content-Type it doesn't know about.

Reproducible: Always

Steps to Reproduce:
#include <string.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <gtkmozembed.h>

int main (int argc, char *argv[])
{

gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *html = gtk_moz_embed_new();
char *data = "Some string";
gtk_container_add(GTK_CONTAINER(window), html);

gtk_widget_show_all(window);

gtk_moz_embed_render_data(GTK_MOZ_EMBED(html), data, strlen(data), "http://mozilla.org", "not-a-valid-content-type");

 gtk_main();

 return 0;
}

Actual Results:  
gtk_moz_embed_render_data is just a wrapper for OpenStream+AppendToStream+CloseStream

At OpenStream nsICategoryManager:getCategoryEntry fails and returns an error. However, return value is not checked and goes on calling AppendToStream, which is not in a state to do so (mStreamListener wasn't initialised).

Same applies with gtk_moz_embed_open_stream, which doesn't check the return value nor provide it to the application, so you can't conditionally append the data.
Workaround: embedPrivate->OpenStream is the last call by gtk_moz_embed_open_stream so (at least on i386) you could cast the void return value to know if it failed.

Expected Results:  
Options:
a) It is open with a generic content-type
b) It guesses the content-type
c) gtk_moz_embed_open_stream and gtk_moz_embed_render_data are changed to return if it has been succesful or not. gtk_moz_embed_render_data stops if OpenStream failed. (EASIEST)
please attach patches instead of simply inlining suggestions. they'll get things further faster.
Severity: major → critical
Keywords: crash
Summary: gtk_moz_embed_render_data crashes if a wrong Content-Type is given → [@ gtk_moz_embed_render_data] crashes if a wrong Content-Type is given
Crash Signature: [@ gtk_moz_embed_render_data]
Product: Core → Core Graveyard
No crashes in the last 4 weeks with this signature.
Also, this bug has no info about current software versions, please file a new bug for new issues or reopen this one with current info, including a crash signature if it still happens and move it to a component outside of graveyard.
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.