Fixed potential crash in add-ons code

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5622 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-07-03 23:48:54 +00:00
parent a8224ea937
commit 56956bf752

View File

@ -64,19 +64,23 @@ MainMenuScreen::MainMenuScreen() : Screen("main.stkgui")
void MainMenuScreen::downloadRss()
{
LabelWidget* w = this->getWidget<LabelWidget>("info_addons");
FILE* fichier = NULL;
char chaine[1000] = "";
fichier = fopen(std::string(file_manager->getConfigDir() + "/news").c_str(), "r+");
std::string info = std::string("");
while (fgets(chaine, 1000, fichier) != NULL) // On lit le fichier tant qu'on ne reçoit pas d'erreur (NULL)
FILE* newsFile = NULL;
char buffer[1024] = "";
newsFile = fopen(std::string(file_manager->getConfigDir() + "/news").c_str(), "r+");
if (newsFile == NULL)
{
info += std::string(chaine);
fprintf(stderr, "Warning: cannot open new files\n");
return;
}
std::string info = std::string("");
while (fgets(buffer, 1024, newsFile) != NULL)
{
info += std::string(buffer);
}
fclose(fichier);
fclose(newsFile);
// to remove the break line.
//info.replace(info.size()-1,1, "");
std::cout << info << std::endl;