Version 18.7.4

This commit is contained in:
Antonio Cañas Vargas 2018-10-18 20:06:54 +02:00
parent 7ffe31f659
commit ef6631b5ac
43 changed files with 234 additions and 200 deletions

View File

@ -144,7 +144,7 @@ void ID_ReallocateListIDs (struct UsrData *UsrDat,unsigned NumIDs)
/***** Allocate space for the list *****/
if ((UsrDat->IDs.List = (struct ListIDs *) malloc (NumIDs * sizeof (struct ListIDs))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of user's IDs.");
Lay_NotEnoughMemoryExit ();
}
/*****************************************************************************/
@ -191,7 +191,7 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
/***** Allocate memory for query string *****/
MaxLength = 512 + UsrDat->IDs.Num * (1 + ID_MAX_BYTES_USR_ID + 1) - 1;
if ((Query = (char *) malloc (MaxLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of user's IDs.");
Lay_NotEnoughMemoryExit ();
/***** Get user's code(s) from database *****/
Str_Copy (Query,CheckPassword ? "SELECT DISTINCT(usr_IDs.UsrCod) FROM usr_IDs,usr_data"

View File

@ -25,6 +25,8 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include <string.h> // For string functions
#include "swad_account.h"
@ -181,7 +183,7 @@ void Acc_CheckIfEmptyAccountExists (void)
unsigned NumUsrs;
unsigned NumUsr;
struct UsrData UsrDat;
char Query[512];
char *Query;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
@ -201,13 +203,15 @@ void Acc_CheckIfEmptyAccountExists (void)
/***** Check if there are users with this user's ID *****/
if (ID_CheckIfUsrIDIsValid (ID))
{
sprintf (Query,"SELECT usr_IDs.UsrCod"
" FROM usr_IDs,usr_data"
" WHERE usr_IDs.UsrID='%s'"
" AND usr_IDs.UsrCod=usr_data.UsrCod"
" AND usr_data.Password=''",
ID);
if (asprintf (&Query,"SELECT usr_IDs.UsrCod"
" FROM usr_IDs,usr_data"
" WHERE usr_IDs.UsrID='%s'"
" AND usr_IDs.UsrCod=usr_data.UsrCod"
" AND usr_data.Password=''",
ID) < 0)
Lay_NotEnoughMemoryExit ();
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get user's codes");
free ((void *) Query);
if (NumUsrs)
{
@ -608,7 +612,7 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES
extern const char *Txt_The_nickname_entered_X_is_not_valid_;
extern const char *Txt_The_email_address_X_had_been_registered_by_another_user;
extern const char *Txt_The_email_address_entered_X_is_not_valid;
char Query[256 + Cns_MAX_CHARS_EMAIL_ADDRESS];
char *Query;
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewPlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1];
bool Error = false;
@ -631,9 +635,10 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES
{
/* Check if the new nickname
matches any of the nicknames of other users */
sprintf (Query,"SELECT COUNT(*) FROM usr_nicknames"
" WHERE Nickname='%s' AND UsrCod<>%ld",
NewNicknameWithoutArroba,Gbl.Usrs.Me.UsrDat.UsrCod);
if (asprintf (&Query,"SELECT COUNT(*) FROM usr_nicknames"
" WHERE Nickname='%s' AND UsrCod<>%ld",
NewNicknameWithoutArroba,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
if (DB_QueryCOUNT (Query,"can not check if nickname already existed")) // A nickname of another user is the same that this nickname
{
Error = true;
@ -642,6 +647,7 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES
NewNicknameWithoutArroba);
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
}
free ((void *) Query);
}
else // New nickname is not valid
{
@ -661,9 +667,10 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES
{
/* Check if the new email matches
any of the confirmed emails of other users */
sprintf (Query,"SELECT COUNT(*) FROM usr_emails"
" WHERE E_mail='%s' AND Confirmed='Y'",
NewEmail);
if (asprintf (&Query,"SELECT COUNT(*) FROM usr_emails"
" WHERE E_mail='%s' AND Confirmed='Y'",
NewEmail) < 0)
Lay_NotEnoughMemoryExit ();
if (DB_QueryCOUNT (Query,"can not check if email already existed")) // An email of another user is the same that my email
{
Error = true;
@ -672,6 +679,7 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES
NewEmail);
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
}
free ((void *) Query);
}
else // New email is not valid
{
@ -710,7 +718,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1];
char *QueryUsrData;
size_t CommentsLength;
char QueryUsrIDs[256 + ID_MAX_BYTES_USR_ID];
char *QueryUsrIDs;
char PathRelUsr[PATH_MAX + 1];
unsigned NumID;
@ -731,57 +739,46 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
CommentsLength = strlen (UsrDat->Comments);
else
CommentsLength = 0;
if ((QueryUsrData = (char *) malloc (2048 +
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + // EncryptedUsrCod
Pwd_BYTES_ENCRYPTED_PASSWORD + // Password
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME * 3 + // Surname1, Surname2, FirstName
Usr_MAX_BYTES_ADDRESS + // LocalAddress
Usr_MAX_BYTES_PHONE + // LocalPhone
Usr_MAX_BYTES_ADDRESS + // FamilyAddress
Usr_MAX_BYTES_PHONE + // FamilyPhone
Usr_MAX_BYTES_ADDRESS + // OriginPlace
Usr_BIRTHDAY_STR_DB_LENGTH + // BirthdayStrDB
CommentsLength)) == NULL) // Comments
Lay_ShowErrorAndExit ("Not enough memory to store query.");
sprintf (QueryUsrData,"INSERT INTO usr_data"
" (EncryptedUsrCod,Password,"
"Surname1,Surname2,FirstName,Sex,"
"Theme,IconSet,Language,FirstDayOfWeek,DateFormat,"
"PhotoVisibility,ProfileVisibility,"
"CtyCod,"
"LocalAddress,LocalPhone,"
"FamilyAddress,FamilyPhone,"
"OriginPlace,Birthday,Comments,"
"Menu,SideCols,NotifNtfEvents,EmailNtfEvents)"
" VALUES"
" ('%s','%s',"
"'%s','%s','%s','%s',"
"'%s','%s','%s',%u,%u,"
"'%s','%s',"
"%ld,"
"'%s','%s',"
"'%s','%s','%s',"
"%s,'%s',"
"%u,%u,-1,0)",
UsrDat->EncryptedUsrCod,
UsrDat->Password,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
Usr_StringsSexDB[UsrDat->Sex],
The_ThemeId[UsrDat->Prefs.Theme],
Ico_IconSetId[UsrDat->Prefs.IconSet],
Txt_STR_LANG_ID[UsrDat->Prefs.Language],
Cal_FIRST_DAY_OF_WEEK_DEFAULT,
(unsigned) Dat_FORMAT_DEFAULT,
Pri_VisibilityDB[UsrDat->PhotoVisibility],
Pri_VisibilityDB[UsrDat->ProfileVisibility],
UsrDat->CtyCod,
UsrDat->LocalAddress ,UsrDat->LocalPhone,
UsrDat->FamilyAddress,UsrDat->FamilyPhone,UsrDat->OriginPlace,
BirthdayStrDB,
CommentsLength ? UsrDat->Comments :
"",
(unsigned) Mnu_MENU_DEFAULT,
(unsigned) Cfg_DEFAULT_COLUMNS);
if (asprintf (&QueryUsrData,"INSERT INTO usr_data"
" (EncryptedUsrCod,Password,"
"Surname1,Surname2,FirstName,Sex,"
"Theme,IconSet,Language,FirstDayOfWeek,DateFormat,"
"PhotoVisibility,ProfileVisibility,"
"CtyCod,"
"LocalAddress,LocalPhone,"
"FamilyAddress,FamilyPhone,"
"OriginPlace,Birthday,Comments,"
"Menu,SideCols,NotifNtfEvents,EmailNtfEvents)"
" VALUES"
" ('%s','%s',"
"'%s','%s','%s','%s',"
"'%s','%s','%s',%u,%u,"
"'%s','%s',"
"%ld,"
"'%s','%s',"
"'%s','%s','%s',"
"%s,'%s',"
"%u,%u,-1,0",
UsrDat->EncryptedUsrCod,
UsrDat->Password,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
Usr_StringsSexDB[UsrDat->Sex],
The_ThemeId[UsrDat->Prefs.Theme],
Ico_IconSetId[UsrDat->Prefs.IconSet],
Txt_STR_LANG_ID[UsrDat->Prefs.Language],
Cal_FIRST_DAY_OF_WEEK_DEFAULT,
(unsigned) Dat_FORMAT_DEFAULT,
Pri_VisibilityDB[UsrDat->PhotoVisibility],
Pri_VisibilityDB[UsrDat->ProfileVisibility],
UsrDat->CtyCod,
UsrDat->LocalAddress ,UsrDat->LocalPhone,
UsrDat->FamilyAddress,UsrDat->FamilyPhone,UsrDat->OriginPlace,
BirthdayStrDB,
CommentsLength ? UsrDat->Comments :
"",
(unsigned) Mnu_MENU_DEFAULT,
(unsigned) Cfg_DEFAULT_COLUMNS) < 0)
Lay_NotEnoughMemoryExit ();
UsrDat->UsrCod = DB_QueryINSERTandReturnCode (QueryUsrData,
"can not create user");
free ((void *) QueryUsrData);
@ -792,15 +789,17 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
NumID++)
{
Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID);
sprintf (QueryUsrIDs,"INSERT INTO usr_IDs"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
UsrDat->UsrCod,
UsrDat->IDs.List[NumID].ID,
UsrDat->IDs.List[NumID].Confirmed ? 'Y' :
'N');
if (asprintf (&QueryUsrIDs,"INSERT INTO usr_IDs"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
UsrDat->UsrCod,
UsrDat->IDs.List[NumID].ID,
UsrDat->IDs.List[NumID].Confirmed ? 'Y' :
'N') < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT (QueryUsrIDs,"can not store user's ID when creating user");
free ((void *) QueryUsrIDs);
}
/***** Create directory for the user, if not exists *****/
@ -1017,7 +1016,7 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
extern const char *Txt_Briefcase_of_THE_USER_X_has_been_removed;
extern const char *Txt_Photo_of_THE_USER_X_has_been_removed;
extern const char *Txt_Record_card_of_THE_USER_X_has_been_removed;
char Query[128];
char *Query;
bool PhotoRemoved = false;
/***** Remove the works zones of the user in all courses *****/
@ -1036,17 +1035,21 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
Grp_RemUsrFromAllGrps (UsrDat->UsrCod);
/***** Remove user's requests for inscription *****/
sprintf (Query,"DELETE FROM crs_usr_requests WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM crs_usr_requests WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove user's requests for inscription");
free ((void *) Query);
/***** Remove user from possible duplicate users *****/
Dup_RemoveUsrFromDuplicated (UsrDat->UsrCod);
/***** Remove user from the table of courses and users *****/
sprintf (Query,"DELETE FROM crs_usr WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM crs_usr WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove a user from all courses");
free ((void *) Query);
if (QuietOrVerbose == Cns_VERBOSE)
{
@ -1057,9 +1060,11 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
}
/***** Remove user as administrator of any degree *****/
sprintf (Query,"DELETE FROM admin WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM admin WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove a user as administrator");
free ((void *) Query);
if (QuietOrVerbose == Cns_VERBOSE)
{
@ -1113,14 +1118,18 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
Ann_RemoveUsrFromSeenAnnouncements (UsrDat->UsrCod);
/***** Remove user from table of connected users *****/
sprintf (Query,"DELETE FROM connected WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM connected WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove a user from table of connected users");
free ((void *) Query);
/***** Remove all sessions of this user *****/
sprintf (Query,"DELETE FROM sessions WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM sessions WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove sessions of a user");
free ((void *) Query);
/***** Remove social content associated to the user *****/
Soc_RemoveUsrSocialContent (UsrDat->UsrCod);
@ -1180,41 +1189,55 @@ static void Acc_RemoveUsrBriefcase (struct UsrData *UsrDat)
static void Acc_RemoveUsr (struct UsrData *UsrDat)
{
char Query[128];
char *Query;
/***** Remove user's webs / social networks *****/
sprintf (Query,"DELETE FROM usr_webs WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM usr_webs WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove user's webs / social networks");
free ((void *) Query);
/***** Remove user's nicknames *****/
sprintf (Query,"DELETE FROM usr_nicknames WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM usr_nicknames WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove user's nicknames");
free ((void *) Query);
/***** Remove user's emails *****/
sprintf (Query,"DELETE FROM pending_emails WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM pending_emails WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove pending user's emails");
free ((void *) Query);
sprintf (Query,"DELETE FROM usr_emails WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM usr_emails WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove user's emails");
free ((void *) Query);
/***** Remove user's IDs *****/
sprintf (Query,"DELETE FROM usr_IDs WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM usr_IDs WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove user's IDs");
free ((void *) Query);
/***** Remove user's last data *****/
sprintf (Query,"DELETE FROM usr_last WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM usr_last WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove user's last data");
free ((void *) Query);
/***** Remove user's data *****/
sprintf (Query,"DELETE FROM usr_data WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (asprintf (&Query,"DELETE FROM usr_data WHERE UsrCod=%ld",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE (Query,"can not remove user's data");
free ((void *) Query);
}
/*****************************************************************************/

View File

@ -1116,7 +1116,7 @@ static void Agd_GetListEvents (Agd_AgendaType_t AgendaType)
/***** Create list of events *****/
if ((Gbl.Agenda.LstAgdCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of agenda events.");
Lay_NotEnoughMemoryExit ();
/***** Get the events codes *****/
for (NumEvent = 0;

View File

@ -676,7 +676,7 @@ void Asg_GetListAssignments (void)
/***** Create list of assignments *****/
if ((Gbl.Asgs.LstAsgCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of assignments.");
Lay_NotEnoughMemoryExit ();
/***** Get the assignments codes *****/
for (NumAsg = 0;

View File

@ -663,7 +663,7 @@ static void Att_GetListAttEvents (Att_OrderTime_t Order)
/***** Create list of attendance events *****/
if ((Gbl.AttEvents.Lst = (struct AttendanceEvent *) calloc (NumRows,sizeof (struct AttendanceEvent))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of attendance events.");
Lay_NotEnoughMemoryExit ();
/***** Get the attendance events codes *****/
for (NumAttEvent = 0;
@ -2466,7 +2466,7 @@ static unsigned Att_GetNumStdsFromAListWhoAreInAttEvent (long AttCod,long LstSel
/***** Allocate space for query *****/
MaxLength = 256 + NumStdsInList * (1 + 1 + 10);
if ((Query = (char *) malloc (MaxLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory for query.");
Lay_NotEnoughMemoryExit ();
/***** Count number of students registered in an event in database *****/
sprintf (Query,"SELECT COUNT(*) FROM att_usr"
@ -2948,7 +2948,7 @@ static void Att_GetListSelectedUsrCods (unsigned NumStdsInList,long **LstSelecte
/***** Create list of user codes *****/
if ((*LstSelectedUsrCods = (long *) calloc ((size_t) NumStdsInList,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of user codes.");
Lay_NotEnoughMemoryExit ();
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
@ -2990,7 +2990,7 @@ static void Att_GetListSelectedAttCods (char **StrAttCodsSelected)
/***** Allocate memory for list of attendance events selected *****/
MaxSizeListAttCodsSelected = Gbl.AttEvents.Num * (1 + 10 + 1);
if ((*StrAttCodsSelected = (char *) malloc (MaxSizeListAttCodsSelected + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of attendance events selected.");
Lay_NotEnoughMemoryExit ();
/***** Get parameter multiple with list of attendance events selected *****/
Par_GetParMultiToText ("AttCods",*StrAttCodsSelected,MaxSizeListAttCodsSelected);

View File

@ -247,7 +247,7 @@ static void Ban_GetListBanners (const char *Query)
/***** Create list with banners *****/
if ((Gbl.Banners.Lst = (struct Banner *) calloc (NumRows,sizeof (struct Banner))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store banners.");
Lay_NotEnoughMemoryExit ();
/***** Get the banners *****/
for (NumBan = 0;

View File

@ -1078,7 +1078,7 @@ void Ctr_GetListCentres (long InsCod)
/***** Create list with courses in degree *****/
if ((Gbl.Ctrs.Lst = (struct Centre *) calloc (NumRows,sizeof (struct Centre))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store centres.");
Lay_NotEnoughMemoryExit ();
/***** Get the centres *****/
for (NumCtr = 0;

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.7.3 (2018-10-18)"
#define Log_PLATFORM_VERSION "SWAD 18.7.4 (2018-10-18)"
#define CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js"
/*
Version 18.7.4: Oct 18, 2018 Some sprintf for database queries changed by asprintf. (236640 lines)
Version 18.7.3: Oct 18, 2018 Changes in layout of list of attendance. (236608 lines)
Version 18.7.2: Oct 18, 2018 Changes in layout of list of attendance. (236602 lines)
Version 18.7.1: Oct 18, 2018 Changes in layout of list of attendance. (236596 lines)

View File

@ -89,7 +89,7 @@ void Cfg_GetConfigFromFile (void)
if ((Config = (char *) malloc (Length + 1)) == NULL)
{
fclose (FileCfg);
Lay_ShowErrorAndExit ("Not enough memory for config.");
Lay_NotEnoughMemoryExit ();
}
/* Copy file content into buffer */

View File

@ -1076,7 +1076,7 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
/***** Create list with countries *****/
if ((Gbl.Ctys.Lst = (struct Country *) calloc (NumRows,sizeof (struct Country))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store countries.");
Lay_NotEnoughMemoryExit ();
/***** Get the countries *****/
for (NumCty = 0;

View File

@ -1010,7 +1010,7 @@ static void Crs_GetListCoursesInDegree (Crs_WhatCourses_t WhatCourses)
{
/***** Create list with courses in degree *****/
if ((Gbl.CurrentDeg.Deg.LstCrss = (struct Course *) calloc ((size_t) NumCrss,sizeof (struct Course))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the courses of a degree.");
Lay_NotEnoughMemoryExit ();
/***** Get the courses in degree *****/
for (NumCrs = 0;

View File

@ -1436,7 +1436,7 @@ void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs)
{
/***** Create list with degrees *****/
if ((Degs->Lst = (struct Degree *) calloc (Degs->Num,sizeof (struct Degree))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store degrees admin by you.");
Lay_NotEnoughMemoryExit ();
/***** Get the degrees *****/
for (NumDeg = 0;
@ -1482,7 +1482,7 @@ void Deg_GetListDegsOfCurrentCtr (void)
/***** Create list with degrees of this centre *****/
if ((Gbl.CurrentCtr.Ctr.Degs.Lst = (struct Degree *) calloc (Gbl.CurrentCtr.Ctr.Degs.Num,
sizeof (struct Degree))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store degrees of a centre.");
Lay_NotEnoughMemoryExit ();
/***** Get the degrees of this centre *****/
for (NumDeg = 0;

View File

@ -657,7 +657,7 @@ void DT_GetListDegreeTypes (Sco_Scope_t Scope,DT_Order_t Order)
{
/***** Create a list of degree types *****/
if ((Gbl.Degs.DegTypes.Lst = (struct DegreeType *) calloc (Gbl.Degs.DegTypes.Num,sizeof (struct DegreeType))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store types of degree.");
Lay_NotEnoughMemoryExit ();
/***** Get degree types *****/
for (NumRow = 0;

View File

@ -306,7 +306,7 @@ void Dpt_GetListDepartments (long InsCod)
/***** Create list with courses in degree *****/
if ((Gbl.Dpts.Lst = (struct Department *) calloc ((size_t) Gbl.Dpts.Num,
sizeof (struct Department))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store departments.");
Lay_NotEnoughMemoryExit ();
/***** Get the departments *****/
for (NumDpt = 0;

View File

@ -550,7 +550,7 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
Usr_MAX_BYTES_ADDRESS + // OriginPlace
Usr_BIRTHDAY_STR_DB_LENGTH + // BirthdayStrDB
CommentsLength)) == NULL) // Comments
Lay_ShowErrorAndExit ("Not enough memory to store query.");
Lay_NotEnoughMemoryExit ();
sprintf (Query,"UPDATE usr_data"
" SET Password='%s',"
"Surname1='%s',Surname2='%s',FirstName='%s',Sex='%s',"
@ -1549,7 +1549,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
/***** Get list of users' IDs *****/
if ((ListUsrsIDs = (char *) malloc (ID_MAX_BYTES_LIST_USRS_IDS + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store users' IDs.");
Lay_NotEnoughMemoryExit ();
Par_GetParToText ("UsrsIDs",ListUsrsIDs,ID_MAX_BYTES_LIST_USRS_IDS);
/***** Initialize structure with user's data *****/
@ -2160,7 +2160,7 @@ void Enr_GetNotifEnrolmentRequest (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
if (asprintf (ContentStr,
"%s", // TODO: Write more info in this content
Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex]) < 0)
Lay_ShowErrorAndExit ("Not enough memory to store string.");
Lay_NotEnoughMemoryExit ();
/* Free memory used for user's data */
Usr_UsrDataDestructor (&UsrDat);

View File

@ -197,25 +197,25 @@ static long Exa_GetParamsExamAnnouncement (void)
static void Exa_AllocMemExamAnnouncement (void)
{
if ((Gbl.ExamAnns.ExaDat.Place = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
Lay_NotEnoughMemoryExit ();
if ((Gbl.ExamAnns.ExaDat.Mode = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
Lay_NotEnoughMemoryExit ();
if ((Gbl.ExamAnns.ExaDat.Structure = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
Lay_NotEnoughMemoryExit ();
if ((Gbl.ExamAnns.ExaDat.DocRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
Lay_NotEnoughMemoryExit ();
if ((Gbl.ExamAnns.ExaDat.MatRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
Lay_NotEnoughMemoryExit ();
if ((Gbl.ExamAnns.ExaDat.MatAllowed = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
Lay_NotEnoughMemoryExit ();
if ((Gbl.ExamAnns.ExaDat.OtherInfo = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
Lay_NotEnoughMemoryExit ();
}
/*****************************************************************************/
@ -742,7 +742,7 @@ static long Exa_AddExamAnnouncementToDB (void)
Hie_MAX_BYTES_FULL_NAME +
Exa_MAX_BYTES_SESSION +
7 * Cns_MAX_BYTES_TEXT)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to query database.");
Lay_NotEnoughMemoryExit ();
sprintf (Query,"INSERT INTO exam_announcements "
"(CrsCod,Status,NumNotif,CrsFullName,Year,ExamSession,"
"CallDate,ExamDate,Duration,"
@ -789,7 +789,7 @@ static void Exa_ModifyExamAnnouncementInDB (void)
Hie_MAX_BYTES_FULL_NAME +
Exa_MAX_BYTES_SESSION +
7 * Cns_MAX_BYTES_TEXT)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to query database.");
Lay_NotEnoughMemoryExit ();
sprintf (Query,"UPDATE exam_announcements"
" SET CrsFullName='%s',Year=%u,ExamSession='%s',"
"ExamDate='%04u-%02u-%02u %02u:%02u:00',"
@ -850,7 +850,7 @@ void Exa_CreateListDatesOfExamAnnouncements (void)
{
/***** Allocate memory for the list *****/
if ((Gbl.ExamAnns.Lst = (struct Date *) calloc (NumExaAnns,sizeof (struct Date))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store dates of exam announcements.");
Lay_NotEnoughMemoryExit ();
/***** Get the dates of the existing exam announcements *****/
for (NumExaAnn = 0;
@ -1708,5 +1708,5 @@ static void Exa_GetNotifContentExamAnnouncement (char **ContentStr)
Txt_EXAM_ANNOUNCEMENT_Material_required,Gbl.ExamAnns.ExaDat.MatRequired,
Txt_EXAM_ANNOUNCEMENT_Material_allowed,Gbl.ExamAnns.ExaDat.MatAllowed,
Txt_EXAM_ANNOUNCEMENT_Other_information,Gbl.ExamAnns.ExaDat.OtherInfo) < 0)
Lay_ShowErrorAndExit ("Not enough memory to store string.");
Lay_NotEnoughMemoryExit ();
}

View File

@ -12535,7 +12535,7 @@ void Brw_GetSummaryAndContentOfFile (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
Txt_Uploaded_by,
FileHasPublisher ? PublisherUsrDat.FullName :
Txt_ROLES_SINGUL_Abc[Rol_UNK][Usr_SEX_UNKNOWN]) < 0)
Lay_ShowErrorAndExit ("Not enough memory to store string.");
Lay_NotEnoughMemoryExit ();
/* Free memory used for publisher's data */
if (FileMetadata.PublisherUsrCod > 0)

View File

@ -515,7 +515,7 @@ static long For_InsertForumPst (long ThrCod,long UsrCod,
Img_BYTES_NAME +
Img_MAX_BYTES_TITLE +
Cns_MAX_BYTES_WWW)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store database query.");
Lay_NotEnoughMemoryExit ();
/***** Check if image is received and processed *****/
if (Image->Action == Img_ACTION_NEW_IMAGE && // Upload new image

View File

@ -997,7 +997,7 @@ void Gam_GetListGames (void)
/***** Create list of games *****/
if ((Gbl.Games.LstGamCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of games.");
Lay_NotEnoughMemoryExit ();
/***** Get the games codes *****/
for (NumGame = 0;
@ -3114,7 +3114,7 @@ static void Gam_AllocateListSelectedQuestions (void)
if (!Gbl.Games.ListQuestions)
{
if ((Gbl.Games.ListQuestions = (char *) malloc (Gam_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of questions.");
Lay_NotEnoughMemoryExit ();;
Gbl.Games.ListQuestions[0] = '\0';
}
}

View File

@ -526,7 +526,7 @@ void Grp_GetParCodsSeveralGrpsToShowUsrs (void)
{
/* Allocate space for list of selected groups */
if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods = (long *) calloc (LstGrpsIBelong.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
Lay_NotEnoughMemoryExit ();
/* Fill list of selected groups with list of groups I belong to */
for (NumGrp = 0;
@ -564,7 +564,7 @@ void Grp_GetParCodsSeveralGrps (void)
{
/***** Allocate memory for the list of group codes selected *****/
if ((ParamLstCodGrps = (char *) malloc (MaxSizeLstGrpCods + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
Lay_NotEnoughMemoryExit ();
/***** Get parameter with list of groups to list *****/
Par_GetParMultiToText ("GrpCods",ParamLstCodGrps,MaxSizeLstGrpCods);
@ -582,7 +582,7 @@ void Grp_GetParCodsSeveralGrps (void)
{
/***** Create a list of groups selected from LstCodGrps *****/
if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods = (long *) calloc (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
Lay_NotEnoughMemoryExit ();
for (Ptr = ParamLstCodGrps, NumGrp = 0;
*Ptr;
NumGrp++)
@ -1030,7 +1030,7 @@ static void Grp_ConstructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **Al
/***** Allocate memory to a list of booleanos that indica if already se ha selected a group of cada type *****/
if ((*AlreadyExistsGroupOfType = (struct ListGrpsAlreadySelec *) calloc (Gbl.CurrentCrs.Grps.GrpTypes.Num,sizeof (struct ListGrpsAlreadySelec))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store type of group.");
Lay_NotEnoughMemoryExit ();
/***** Initialize the list *****/
for (NumGrpTyp = 0;
@ -2726,7 +2726,7 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
{
/***** Create a list of group types *****/
if ((Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes = (struct GroupType *) calloc (Gbl.CurrentCrs.Grps.GrpTypes.Num,sizeof (struct GroupType))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store types of group.");
Lay_NotEnoughMemoryExit ();
/***** Get group types *****/
for (NumRow = 0;
@ -2856,7 +2856,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
/***** Create list with groups of this type *****/
if ((GrpTyp->LstGrps = (struct Group *) calloc (GrpTyp->NumGrps,sizeof (struct Group))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store groups of a type.");
Lay_NotEnoughMemoryExit ();
/***** Get the groups of this type *****/
for (NumGrp = 0;
@ -3536,7 +3536,7 @@ static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
{
/***** Create a list of groups the user belongs to *****/
if ((LstGrps->GrpCods = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store codes of groups a user belongs to.");
Lay_NotEnoughMemoryExit ();
for (NumGrp = 0;
NumGrp < LstGrps->NumGrps;
NumGrp++)
@ -3581,7 +3581,7 @@ void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps)
{
/***** Create a list of groups I belong to *****/
if ((LstGrps->GrpCods = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store codes of groups I belongs to.");
Lay_NotEnoughMemoryExit ();
for (NumGrp = 0;
NumGrp < LstGrps->NumGrps;
NumGrp++)
@ -4775,7 +4775,7 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
/***** Allocate memory for the strings with group codes in each type *****/
if ((LstStrCodGrps = (char **) calloc (Gbl.CurrentCrs.Grps.GrpTypes.Num,sizeof (char *))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store codes of groups in which a user wants to be enroled.");
Lay_NotEnoughMemoryExit ();
/***** Get lists with the groups that I want in each type
in order to count the total number of groups selected *****/
@ -4786,7 +4786,7 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
/***** Allocate memory for the list of group codes of this type *****/
if ((LstStrCodGrps[NumGrpTyp] = (char *) malloc ((size_t) ((1 + 10 + 1) *
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store codes of groups in which a user wants to be enroled.");
Lay_NotEnoughMemoryExit ();
/***** Get the multiple parameter code of group of this type *****/
snprintf (Param,sizeof (Param),

View File

@ -295,7 +295,7 @@ void Hld_GetListHolidays (void)
{
/***** Create list of holidays *****/
if ((Gbl.Hlds.Lst = (struct Holiday *) calloc ((size_t) Gbl.Hlds.Num,sizeof (struct Holiday))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store holidays.");
Lay_NotEnoughMemoryExit ();
/***** Get the holidays *****/
for (NumHld = 0;

View File

@ -903,7 +903,7 @@ int Inf_WritePageIntoHTMLBuffer (char **HTMLBuffer)
if ((*HTMLBuffer = (char *) malloc (Length + 1)) == NULL)
{
fclose (FileHTML);
Lay_ShowErrorAndExit ("Not enough memory for buffer.");
Lay_NotEnoughMemoryExit ();
return soap_receiver_fault (Gbl.soap,
"Web page can not be copied into buffer",
"Not enough memory for buffer");

View File

@ -1016,7 +1016,7 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
/***** Create list with institutions *****/
if ((Gbl.Inss.Lst = (struct Instit *) calloc (NumRows,sizeof (struct Instit))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store institutions.");
Lay_NotEnoughMemoryExit ();
/***** Get the institutions *****/
for (NumIns = 0;

View File

@ -1194,6 +1194,15 @@ void Lay_EndSection (void)
fprintf (Gbl.F.Out,"</section>");
}
/*****************************************************************************/
/********** Write error message and exit when not enough memory **************/
/*****************************************************************************/
void Lay_NotEnoughMemoryExit (void)
{
Lay_NotEnoughMemoryExit ();
}
/*****************************************************************************/
/******* Write error message, close files, remove lock file, and exit ********/
/*****************************************************************************/

View File

@ -66,6 +66,7 @@ void Lay_PutContextualCheckbox (Act_Action_t NextAction,
void Lay_StartSection (const char *SectionId);
void Lay_EndSection (void);
void Lay_NotEnoughMemoryExit (void);
void Lay_ShowErrorAndExit (const char *Txt);
void Lay_RefreshNotifsAndConnected (void);

View File

@ -272,7 +272,7 @@ void Lnk_GetListLinks (void)
/***** Create list with places *****/
if ((Gbl.Links.Lst = (struct Link *) calloc (NumRows,sizeof (struct Link))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store institutional links.");
Lay_NotEnoughMemoryExit ();;
/***** Get the links *****/
for (NumLnk = 0;

View File

@ -271,7 +271,7 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
/***** Create list with places *****/
if ((Gbl.Mails.Lst = (struct Mail *) calloc (NumRows,sizeof (struct Mail))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store mail domains.");
Lay_NotEnoughMemoryExit ();
/***** Get the mail domains *****/
for (NumMai = 0;

View File

@ -880,7 +880,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
fclose (FileUsrMarks);
if (asprintf (ContentStr,"<![CDATA[%s]]>",
Gbl.Alert.Txt) < 0)
Lay_ShowErrorAndExit ("Not enough memory to store string.");
Lay_NotEnoughMemoryExit ();
}
}
else
@ -890,7 +890,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
Ale_MAX_BYTES_ALERT);
if (asprintf (ContentStr,"<![CDATA[%s]]>",
Gbl.Alert.Txt) < 0)
Lay_ShowErrorAndExit ("Not enough memory to store string.");
Lay_NotEnoughMemoryExit ();
}
unlink (FileNameUsrMarks); // File with marks is no longer necessary
}
@ -901,7 +901,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
Ale_MAX_BYTES_ALERT);
if (asprintf (ContentStr,"<![CDATA[%s]]>",
Gbl.Alert.Txt) < 0)
Lay_ShowErrorAndExit ("Not enough memory to store string.");
Lay_NotEnoughMemoryExit ();
}
}
}

View File

@ -1322,7 +1322,7 @@ static long Msg_InsertNewMsg (const char *Subject,const char *Content,
strlen (Content) +
Img_BYTES_NAME +
Img_MAX_BYTES_TITLE)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store database query.");
Lay_NotEnoughMemoryExit ();
/***** Check if image is received and processed *****/
if (Image->Action == Img_ACTION_NEW_IMAGE && // Upload new image

View File

@ -325,7 +325,7 @@ void Plc_GetListPlaces (void)
/***** Create list with courses in centre *****/
if ((Gbl.Plcs.Lst = (struct Place *) calloc (NumRows,sizeof (struct Place))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store places.");
Lay_NotEnoughMemoryExit ();
/***** Get the places *****/
for (NumPlc = 0;

View File

@ -202,7 +202,7 @@ static void Plg_GetListPlugins (void)
/***** Create list with plugins *****/
if ((Gbl.Plugins.Lst = (struct Plugin *) calloc ((size_t) Gbl.Plugins.Num,sizeof (struct Plugin))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store plugins.");
Lay_NotEnoughMemoryExit ();
/***** Get the plugins *****/
for (NumPlg = 0;

View File

@ -2452,7 +2452,7 @@ void Prj_GetListProjects (void)
/***** Create list of projects *****/
if ((Gbl.Prjs.LstPrjCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of projects.");
Lay_NotEnoughMemoryExit ();
/***** Get the projects codes *****/
for (NumPrj = 0;
@ -3198,13 +3198,13 @@ static void Prj_EditOneProjectTxtArea (const char *Id,
void Prj_AllocMemProject (struct Project *Prj)
{
if ((Prj->Description = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store project.");
Lay_NotEnoughMemoryExit ();
if ((Prj->Knowledge = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store project.");
Lay_NotEnoughMemoryExit ();
if ((Prj->Materials = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store project.");
Lay_NotEnoughMemoryExit ();
}
/*****************************************************************************/

View File

@ -242,7 +242,7 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
{
/***** Create a list of fields *****/
if ((Gbl.CurrentCrs.Records.LstFields.Lst = (struct RecordField *) calloc (Gbl.CurrentCrs.Records.LstFields.Num,sizeof (struct RecordField))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store fields of records in current course.");
Lay_NotEnoughMemoryExit ();
/***** Get the fields *****/
for (NumRow = 0;
@ -2095,7 +2095,7 @@ void Rec_AllocMemFieldsRecordsCrs (void)
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
/* Allocate memory for the texts of the fields */
if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store records of the course.");
Lay_NotEnoughMemoryExit ();
}
/*****************************************************************************/

View File

@ -372,7 +372,7 @@ void Ses_InsertHiddenParInDB (Act_Action_t NextAction,
LengthParamName +
LengthParamValue;
if ((Query = (char *) malloc (MaxLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory for query.");
Lay_NotEnoughMemoryExit ();
/***** Insert parameter in the database *****/
sprintf (Query,"INSERT INTO hidden_params"

View File

@ -2305,7 +2305,7 @@ static long Soc_ReceiveSocialPost (void)
Img_BYTES_NAME +
Img_MAX_BYTES_TITLE +
Cns_MAX_BYTES_WWW)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store database query.");
Lay_NotEnoughMemoryExit ();
/***** Check if image is received and processed *****/
if (Image.Action == Img_ACTION_NEW_IMAGE && // Upload new image
@ -3013,7 +3013,7 @@ static long Soc_ReceiveComment (void)
Img_BYTES_NAME +
Img_MAX_BYTES_TITLE +
Cns_MAX_BYTES_WWW)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store database query.");
Lay_NotEnoughMemoryExit ();
/***** Check if image is received and processed *****/
if (Image.Action == Img_ACTION_NEW_IMAGE && // Upload new image

View File

@ -321,7 +321,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
ParamsStr);
Anchor1NickLength = strlen (Anchor1Nick);
if ((Links[NumLinks].Anchor1Nick = (char *) malloc (Anchor1NickLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to insert link.");
Lay_NotEnoughMemoryExit ();
strcpy (Links[NumLinks].Anchor1Nick,Anchor1Nick);
Links[NumLinks].Anchor1NickLength = Anchor1NickLength;
@ -335,7 +335,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
Gbl.Form.Id);
Anchor2NickLength = strlen (Anchor2Nick);
if ((Links[NumLinks].Anchor2Nick = (char *) malloc (Anchor2NickLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to insert link.");
Lay_NotEnoughMemoryExit ();
strcpy (Links[NumLinks].Anchor2Nick,Anchor2Nick);
Links[NumLinks].Anchor2NickLength = Anchor2NickLength;
@ -1054,7 +1054,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
{
/***** Allocate memory for a destination string where to do the changes *****/
if ((StrDst = (char *) malloc (MaxLengthStr + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to change the format of a string.");
Lay_NotEnoughMemoryExit ();
/***** Make the change *****/
for (PtrSrc = Str, PtrDst = StrDst;

View File

@ -960,7 +960,7 @@ void Svy_GetListSurveys (void)
/***** Create list of surveys *****/
if ((Gbl.Svys.LstSvyCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of surveys.");
Lay_NotEnoughMemoryExit ();
/***** Get the surveys codes *****/
for (NumSvy = 0;
@ -3396,7 +3396,7 @@ static void Svy_WriteQstStem (const char *Stem)
/* Convert the stem, that is in HTML, to rigorous HTML */
Length = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
if ((HeadingRigorousHTML = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store stem of question.");
Lay_NotEnoughMemoryExit ();
Str_Copy (HeadingRigorousHTML,Stem,
Length);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,

View File

@ -374,7 +374,7 @@ void Syl_LoadListItemsSyllabusIntoMemory (long CrsCod)
/***** Allocate memory for the list of items *****/
if ((LstItemsSyllabus.Lst = (struct ItemSyllabus *) calloc (LstItemsSyllabus.NumItems + 1,sizeof (struct ItemSyllabus))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store syllabus.");
Lay_NotEnoughMemoryExit ();
/***** Return to the start of the list *****/
fseek (Gbl.F.XML,PostBeginList,SEEK_SET);

View File

@ -1082,7 +1082,7 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem)
/***** Convert the stem, that is in HTML, to rigorous HTML *****/
StemLength = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
if ((StemRigorousHTML = (char *) malloc (StemLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store stem of question.");
Lay_NotEnoughMemoryExit ();
Str_Copy (StemRigorousHTML,Stem,
StemLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
@ -1216,7 +1216,7 @@ void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback)
/***** Convert the feedback, that is in HTML, to rigorous HTML *****/
FeedbackLength = strlen (Feedback) * Str_MAX_BYTES_PER_CHAR;
if ((FeedbackRigorousHTML = (char *) malloc (FeedbackLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store stem of question.");
Lay_NotEnoughMemoryExit ();
Str_Copy (FeedbackRigorousHTML,Feedback,
FeedbackLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
@ -3410,7 +3410,7 @@ static void Tst_WriteAnswersEdit (long QstCod)
/* Convert the answer (row[1]), that is in HTML, to rigorous HTML */
LengthAnswer = strlen (row[1]) * Str_MAX_BYTES_PER_CHAR;
if ((Answer = (char *) malloc (LengthAnswer + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store answer.");
Lay_NotEnoughMemoryExit ();
Str_Copy (Answer,row[1],
LengthAnswer);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
@ -3424,7 +3424,7 @@ static void Tst_WriteAnswersEdit (long QstCod)
{
LengthFeedback = strlen (row[2]) * Str_MAX_BYTES_PER_CHAR;
if ((Feedback = (char *) malloc (LengthFeedback + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store feedback.");
Lay_NotEnoughMemoryExit ();
Str_Copy (Feedback,row[2],
LengthFeedback);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
@ -4743,7 +4743,7 @@ static bool Tst_GetParamsTst (Tst_ActionToDoWithQuestions_t ActionToDoWithQuesti
/* Get the tags */
if ((Gbl.Test.Tags.List = (char *) malloc (Tst_MAX_BYTES_TAGS_LIST + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store tags.");
Lay_NotEnoughMemoryExit ();
Par_GetParMultiToText ("ChkTag",Gbl.Test.Tags.List,Tst_MAX_BYTES_TAGS_LIST);
/* Check number of tags selected */
@ -6559,7 +6559,7 @@ static void Tst_InsertOrUpdateQstIntoDB (void)
Img_BYTES_NAME +
Img_MAX_BYTES_TITLE +
Cns_MAX_BYTES_WWW)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store database query.");
Lay_NotEnoughMemoryExit ();
if (Gbl.Test.QstCod < 0) // It's a new question
{
@ -6670,7 +6670,7 @@ static void Tst_InsertAnswersIntoDB (void)
Img_BYTES_NAME +
Img_MAX_BYTES_TITLE +
Cns_MAX_BYTES_WWW)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store database query.");
Lay_NotEnoughMemoryExit ();
/***** Insert answers in the answers table *****/
switch (Gbl.Test.AnswerType)

View File

@ -468,7 +468,7 @@ static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML)
/***** Allocate memory for XML buffer *****/
if ((XMLBuffer = (char *) malloc (FileSize + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory for XML buffer.");
Lay_NotEnoughMemoryExit ();
else
{
/***** Read file contents into XML buffer *****/
@ -732,7 +732,7 @@ static bool TsI_CheckIfQuestionExistsInDB (void)
/***** Check if stem exists *****/
/* Allocate space for query */
if ((QueryQst = (char *) malloc (256 + Gbl.Test.Stem.Length)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store database query.");
Lay_NotEnoughMemoryExit ();
/* Make database query */
sprintf (QueryQst,"SELECT QstCod FROM tst_questions"
@ -1134,7 +1134,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
AnswerTextLength = strlen (Gbl.Test.Answer.Options[NumOpt].Text) *
Str_MAX_BYTES_PER_CHAR;
if ((AnswerText = (char *) malloc (AnswerTextLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store answer.");
Lay_NotEnoughMemoryExit ();
Str_Copy (AnswerText,Gbl.Test.Answer.Options[NumOpt].Text,
AnswerTextLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
@ -1149,7 +1149,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
AnswerFeedbackLength = strlen (Gbl.Test.Answer.Options[NumOpt].Feedback) *
Str_MAX_BYTES_PER_CHAR;
if ((AnswerFeedback = (char *) malloc (AnswerFeedbackLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store feedback.");
Lay_NotEnoughMemoryExit ();
Str_Copy (AnswerFeedback,
Gbl.Test.Answer.Options[NumOpt].Feedback,
AnswerFeedbackLength);

View File

@ -279,7 +279,7 @@ void Usr_UsrDataConstructor (struct UsrData *UsrDat)
{
/***** Allocate memory for the comments *****/
if ((UsrDat->Comments = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store user's data.");
Lay_NotEnoughMemoryExit ();
/***** Initialize to zero the data of the user *****/
Usr_ResetUsrDataExceptUsrCodAndIDs (UsrDat);
@ -392,7 +392,7 @@ void Usr_GetAllUsrDataFromUsrCod (struct UsrData *UsrDat)
void Usr_AllocateListUsrCods (struct ListUsrCods *ListUsrCods)
{
if ((ListUsrCods->Lst = (long *) malloc (ListUsrCods->NumUsrs * sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of users' codes.");
Lay_NotEnoughMemoryExit ();
}
/*****************************************************************************/
@ -4283,7 +4283,7 @@ static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,
/***** Allocate memory for list of booleans AddStdsWithoutGroupOf *****/
if ((AddStdsWithoutGroupOf = (bool *) calloc (Gbl.CurrentCrs.Grps.GrpTypes.Num,sizeof (bool))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store types of group.");
Lay_NotEnoughMemoryExit ();
/***** Initialize vector of booleans that indicates whether it's necessary add to the list
the students who don't belong to any group of each type *****/
@ -5345,7 +5345,7 @@ if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
*/
if (Gbl.Usrs.LstUsrs[Role].NumUsrs)
if ((Gbl.Usrs.LstUsrs[Role].Lst = (struct UsrInList *) calloc (Gbl.Usrs.LstUsrs[Role].NumUsrs,sizeof (struct UsrInList))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store users list.");
Lay_NotEnoughMemoryExit ();
}
/*****************************************************************************/
@ -5737,7 +5737,7 @@ static void Usr_AllocateListSelectedUsrCod (Rol_Role_t Role)
if (!Gbl.Usrs.Select[Role])
{
if ((Gbl.Usrs.Select[Role] = (char *) malloc (Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of users.");
Lay_NotEnoughMemoryExit ();
Gbl.Usrs.Select[Role][0] = '\0';
}
}
@ -5770,7 +5770,7 @@ static void Usr_AllocateListOtherRecipients (void)
if (!Gbl.Usrs.ListOtherRecipients)
{
if ((Gbl.Usrs.ListOtherRecipients = (char *) malloc (Nck_MAX_BYTES_LIST_NICKS + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store list of recipients.");
Lay_NotEnoughMemoryExit ();
Gbl.Usrs.ListOtherRecipients[0] = '\0';
}
}
@ -6186,7 +6186,7 @@ static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr)
/***** Allocate memory for the string with the list of group names where student belongs to *****/
if ((GroupNames = (char *) malloc ((Grp_MAX_BYTES_GROUP_NAME + 3) *
Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store names of groups.");
Lay_NotEnoughMemoryExit ();
/***** Start table with list of students *****/
if (!Gbl.Usrs.ClassPhoto.AllGroups)
@ -6513,7 +6513,7 @@ void Usr_ListAllDataStds (void)
{
Length = (Grp_MAX_BYTES_GROUP_NAME + 2) * Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal;
if ((GroupNames = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store names of groups.");
Lay_NotEnoughMemoryExit ();
}
/***** Start table with list of students *****/

View File

@ -1937,7 +1937,7 @@ int swad__sendMyGroups (struct soap *soap,
{
/***** Create a list of groups selected from myGroups *****/
if ((LstGrpsIWant.GrpCods = (long *) calloc (LstGrpsIWant.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
Lay_NotEnoughMemoryExit ();
for (NumGrp = 0, Ptr = myGroups;
*Ptr;
NumGrp++)
@ -2491,7 +2491,7 @@ static void Svc_GetLstGrpsSel (const char *Groups)
Gbl.CurrentCrs.Grps.LstGrpsSel.NestedCalls++;
// Here NestedCalls is always 1
if ((Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods = (long *) calloc (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store the codes of the selected groups.");
Lay_NotEnoughMemoryExit ();
for (Ptr = Groups, NumGrp = 0;
*Ptr;

View File

@ -100,7 +100,7 @@ void XML_GetTree (const char *XMLBuffer,struct XMLElement **XMLRootElem)
{
/***** Allocate space for the root element *****/
if ((*XMLRootElem = calloc (1,sizeof (struct XMLElement))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory for XML element.");
Lay_NotEnoughMemoryExit ();
Gbl.XMLPtr = XMLBuffer;
XML_GetElement (*XMLRootElem);
@ -183,7 +183,7 @@ static void XML_GetElement (struct XMLElement *ParentElem)
if (ContentLength)
{
if ((ParentElem->Content = (char *) malloc (ContentLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory.");
Lay_NotEnoughMemoryExit ();
strncpy (ParentElem->Content,StartContent,ContentLength);
ParentElem->Content[ContentLength] = '\0';
ParentElem->ContentLength = ContentLength;
@ -208,7 +208,7 @@ static void XML_GetElement (struct XMLElement *ParentElem)
*/
/***** Allocate space for the child element *****/
if ((ChildElem = calloc (1,sizeof (struct XMLElement))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory for XML element.");
Lay_NotEnoughMemoryExit ();
/***** Adjust XML elements pointers *****/
if (ParentElem->FirstChild) // This child is a brother of a former child
@ -220,7 +220,7 @@ static void XML_GetElement (struct XMLElement *ParentElem)
/***** Get child tag name *****/
ChildElem->TagNameLength = strcspn (Gbl.XMLPtr,">/ \t");
if ((ChildElem->TagName = (char *) malloc (ChildElem->TagNameLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory.");
Lay_NotEnoughMemoryExit ();
strncpy (ChildElem->TagName,Gbl.XMLPtr,ChildElem->TagNameLength);
ChildElem->TagName[ChildElem->TagNameLength] = '\0';
Gbl.XMLPtr += ChildElem->TagNameLength;
@ -328,7 +328,7 @@ static void XML_GetAttributes (struct XMLElement *Elem)
*/
/***** Allocate space for the attribute *****/
if ((Attribute = calloc (1,sizeof (struct XMLAttribute))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory for XML attribute.");
Lay_NotEnoughMemoryExit ();
/***** Adjust XML element and attribute pointers *****/
if (Elem->FirstAttribute) // This attribute is a brother of a former attribute in current element
@ -340,7 +340,7 @@ static void XML_GetAttributes (struct XMLElement *Elem)
/***** Get attribute name *****/
Attribute->AttributeNameLength = strcspn (Gbl.XMLPtr,"=");
if ((Attribute->AttributeName = (char *) malloc (Attribute->AttributeNameLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory.");
Lay_NotEnoughMemoryExit ();
strncpy (Attribute->AttributeName,Gbl.XMLPtr,Attribute->AttributeNameLength);
Attribute->AttributeName[Attribute->AttributeNameLength] = '\0';
Gbl.XMLPtr += Attribute->AttributeNameLength;
@ -371,7 +371,7 @@ static void XML_GetAttributes (struct XMLElement *Elem)
}
if ((Attribute->Content = (char *) malloc (Attribute->ContentLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory.");
Lay_NotEnoughMemoryExit ();
strncpy (Attribute->Content,Gbl.XMLPtr,Attribute->ContentLength);
Attribute->Content[Attribute->ContentLength] = '\0';
Gbl.XMLPtr += Attribute->ContentLength;