Protect Gswe*Data from NULL pointers

This commit is contained in:
gitolite tester 2014-11-01 01:24:06 +01:00
parent c461b743e4
commit 5b7124aca5
4 changed files with 16 additions and 0 deletions

View File

@ -220,6 +220,10 @@ gswe_antiscion_data_ref(GsweAntiscionData *antiscion_data)
void void
gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data) gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data)
{ {
if (antiscion_data == NULL) {
return;
}
if (--antiscion_data->refcount == 0) { if (--antiscion_data->refcount == 0) {
gswe_antiscion_data_free(antiscion_data); gswe_antiscion_data_free(antiscion_data);
} }

View File

@ -203,6 +203,10 @@ gswe_aspect_data_ref(GsweAspectData *aspect_data)
void void
gswe_aspect_data_unref(GsweAspectData *aspect_data) gswe_aspect_data_unref(GsweAspectData *aspect_data)
{ {
if (aspect_data == NULL) {
return;
}
if (--aspect_data->refcount == 0) { if (--aspect_data->refcount == 0) {
gswe_aspect_data_free(aspect_data); gswe_aspect_data_free(aspect_data);
} }

View File

@ -88,6 +88,10 @@ gswe_moon_phase_data_ref(GsweMoonPhaseData *moon_phase_data)
void void
gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data) gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data)
{ {
if (moon_phase_data == NULL) {
return;
}
if (--moon_phase_data->refcount == 0) { if (--moon_phase_data->refcount == 0) {
g_free(moon_phase_data); g_free(moon_phase_data);
} }

View File

@ -99,6 +99,10 @@ gswe_planet_data_ref(GswePlanetData *planet_data)
void void
gswe_planet_data_unref(GswePlanetData *planet_data) gswe_planet_data_unref(GswePlanetData *planet_data)
{ {
if (planet_data == NULL) {
return;
}
if (--planet_data->refcount == 0) { if (--planet_data->refcount == 0) {
gswe_planet_data_free(planet_data); gswe_planet_data_free(planet_data);
} }